2 ===================================================================
3 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/DepTable.C,v
4 retrieving revision 1.41
5 diff -u -r1.41 DepTable.C
6 --- src/DepTable.C 13 Oct 2003 01:01:33 -0000 1.41
7 +++ src/DepTable.C 19 Jan 2005 10:35:54 -0000
11 #ifndef CXX_GLOBAL_CSTD
17 using lyx::support::ltrim;
19 ===================================================================
20 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
21 retrieving revision 1.609
22 diff -u -r1.609 buffer.C
23 --- src/buffer.C 31 Jan 2005 10:42:17 -0000 1.609
24 +++ src/buffer.C 31 Jan 2005 11:08:10 -0000
26 #include <boost/bind.hpp>
27 #include <boost/filesystem/operations.hpp>
31 +# include <windows.h>
39 ===================================================================
40 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
41 retrieving revision 1.119
42 diff -u -r1.119 cursor.C
43 --- src/cursor.C 18 Jan 2005 14:15:55 -0000 1.119
44 +++ src/cursor.C 31 Jan 2005 11:08:09 -0000
48 #ifndef CXX_GLOBAL_CSTD
56 ===================================================================
57 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ispell.C,v
58 retrieving revision 1.25
59 diff -u -r1.25 ispell.C
60 --- src/ispell.C 20 Jan 2005 16:17:36 -0000 1.25
61 +++ src/ispell.C 23 Jan 2005 12:09:37 -0000
64 #include "support/forkedcall.h"
67 +# include "support/os_win32.h"
70 // HP-UX 11.x doesn't have this header
71 #ifdef HAVE_SYS_SELECT_H
72 #include <sys/select.h>
74 -#include <sys/time.h>
76 +# include <sys/time.h>
79 using boost::shared_ptr;
86 dup2(pipein[0], STDIN_FILENO);
87 dup2(pipeout[1], STDOUT_FILENO);
88 dup2(pipeerr[1], STDERR_FILENO);
91 lyxerr << "LyX: Failed to start ispell!" << endl;
99 lyxerr[Debug::GUI] << "Created ispell" << endl;
102 // static due to the setvbuf. Ugly.
103 static char o_buf[BUFSIZ];
113 @@ -295,18 +305,23 @@
129 bool ISpell::select(bool & err_read)
137 @@ -316,11 +331,15 @@
142 retval = ::select(SELECT_TYPE_ARG1 (max(pipeout[0], pipeerr[0]) + 1),
143 SELECT_TYPE_ARG234 (&infds),
146 SELECT_TYPE_ARG5 (&tv));
154 fgets(buf, BUFSIZ, in);
162 ===================================================================
163 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
164 retrieving revision 1.247
165 diff -u -r1.247 lyx_cb.C
166 --- src/lyx_cb.C 31 Jan 2005 10:42:18 -0000 1.247
167 +++ src/lyx_cb.C 31 Jan 2005 10:57:53 -0000
169 #include "support/path.h"
170 #include "support/systemcall.h"
173 +# include "support/os_win32.h" // fork()
176 #include <boost/shared_ptr.hpp>
177 #include <boost/filesystem/operations.hpp>
179 Index: src/lyxserver.C
180 ===================================================================
181 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
182 retrieving revision 1.59
183 diff -u -r1.59 lyxserver.C
184 --- src/lyxserver.C 20 Jan 2005 15:07:36 -0000 1.59
185 +++ src/lyxserver.C 21 Jan 2005 09:47:31 -0000
187 #include <sys/stat.h>
191 +# include "support/os_win32.h" // F_SETFL, O_NONBLOCK, fcntl
198 // Imported handles can be used both with OS/2 APIs and emx
199 // library functions.
200 fd = _imphandle(os2fd);
201 +#elif defined(_WIN32)
204 if (::access(filename.c_str(), F_OK) == 0) {
205 lyxerr << "LyXComm: Pipe " << filename << " already exists.\n"
206 @@ -236,10 +242,12 @@
211 if (::close(fd) < 0) {
212 lyxerr << "LyXComm: Could not close pipe " << filename
213 << '\n' << strerror(errno) << endl;
217 // OS/2 pipes are deleted automatically
222 // the single = is intended here.
223 - while ((status = ::read(infd, charbuf, charbuf_size - 1))) {
226 + ::read(infd, charbuf, charbuf_size - 1)
233 charbuf[status] = '\0'; // turn it into a c string
236 if (pipename.empty()) return;
242 lyxerr << "LyXComm: Pipes are closed. Could not send "
252 Index: src/lyxsocket.C
253 ===================================================================
254 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxsocket.C,v
255 retrieving revision 1.6
256 diff -u -r1.6 lyxsocket.C
257 --- src/lyxsocket.C 23 Jul 2004 19:01:48 -0000 1.6
258 +++ src/lyxsocket.C 19 Jan 2005 11:18:01 -0000
260 LyXServerSocket::~LyXServerSocket()
262 lyx_gui::unregister_socket_callback(fd_);
266 lyx::support::unlink(address_);
267 lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl;
271 string const linen(line + '\n');
272 int const size = linen.size();
274 int const written = ::write(fd_, linen.c_str(), size);
276 + int const written = -1;
278 if (written < size) { // Allways mean end of connection.
279 if ((written == -1) && (errno == EPIPE)) {
280 // The program will also receive a SIGPIPE
283 LyXDataSocket::~LyXDataSocket()
289 lyx_gui::unregister_socket_callback(fd_);
290 lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
294 // read and store characters in buffer
295 - while ((count = ::read(fd_, charbuf, charbuf_size - 1)) > 0) {
298 + ::read(fd_, charbuf, charbuf_size - 1)
303 buffer_.append(charbuf, charbuf + count);
308 string const linen(line + '\n');
309 int const size = linen.size();
311 int const written = ::write(fd_, linen.c_str(), size);
313 + int const written = -1;
315 if (written < size) { // Allways mean end of connection.
316 if ((written == -1) && (errno == EPIPE)) {
317 // The program will also receive a SIGPIPE
318 Index: src/client/client.C
319 ===================================================================
320 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/client/client.C,v
321 retrieving revision 1.7
322 diff -u -r1.7 client.C
323 --- src/client/client.C 20 Jan 2005 15:38:13 -0000 1.7
324 +++ src/client/client.C 21 Jan 2005 09:43:09 -0000
331 -#include <sys/select.h>
332 +# include <sys/select.h>
334 // socket(), connect()
335 -#include <sys/socket.h>
337 +# include <sys/socket.h>
338 +# include <sys/un.h>
343 Index: src/frontends/LyXView.C
344 ===================================================================
345 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
346 retrieving revision 1.49
347 diff -u -r1.49 LyXView.C
348 --- src/frontends/LyXView.C 20 Jan 2005 15:38:14 -0000 1.49
349 +++ src/frontends/LyXView.C 21 Jan 2005 09:43:10 -0000
352 #include <boost/bind.hpp>
354 -#include <sys/time.h>
356 +# include <sys/time.h>
361 Index: src/support/filetools.C
362 ===================================================================
363 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
364 retrieving revision 1.204
365 diff -u -r1.204 filetools.C
366 --- src/support/filetools.C 31 Jan 2005 10:42:23 -0000 1.204
367 +++ src/support/filetools.C 31 Jan 2005 11:08:10 -0000
368 @@ -1153,6 +1153,11 @@
370 cmd_ret const RunCommand(string const & cmd)
373 + // TODO: Implement this, or merge it into forkedcall.
374 + // Used for lyx2lyx in buffer.C, echo in math_extern and kpse in this file
375 + return make_pair(-1, string());
377 // FIXME: replace all calls to RunCommand with ForkedCall
378 // (if the output is not needed) or the code in ispell.C
379 // (if the output is needed).
380 @@ -1193,6 +1198,7 @@
381 sigprocmask(SIG_SETMASK, &oldMask, 0);
383 return make_pair(pret, ret);
388 Index: src/support/forkedcall.C
389 ===================================================================
390 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.C,v
391 retrieving revision 1.21
392 diff -u -r1.21 forkedcall.C
393 --- src/support/forkedcall.C 20 Jan 2005 15:38:14 -0000 1.21
394 +++ src/support/forkedcall.C 25 Jan 2005 12:41:14 -0000
396 #include "support/lyxlib.h"
397 #include "support/filetools.h"
398 #include "support/os.h"
400 +#include "os_win32.h"
401 +#include <process.h>
409 #include <sys/types.h>
410 -#include <sys/wait.h>
412 +# include <sys/wait.h>
419 new Murder(secs, pid);
420 } else if (pid != 0) {
422 lyx::support::kill(pid, SIGKILL);
432 lyx::support::kill(pid_, SIGKILL);
435 lyxerr << "Killed " << pid_ << std::endl;
437 @@ -152,14 +162,16 @@
442 // Un-UNIX like, but we don't have much use for
443 // knowing if a zombie exists, so just reap it first.
445 waitpid(pid(), &waitstatus, WNOHANG);
447 // Racy of course, but it will do.
448 - if (::kill(pid(), 0) && errno == ESRCH)
449 + if (lyx::kill(pid(), 0) && errno == ESRCH)
456 Murder::killItDead(0, pid());
460 int ret = lyx::support::kill(pid(), SIGHUP);
462 // The process is already dead if wait_for_death is false
464 if (wait_for_death) {
465 Murder::killItDead(tolerance, pid());
473 // We'll pretend that the child returns 1 on all error conditions.
488 std::cout << *ait << std::endl;
493 + pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
494 + argv[0], &*argv.begin());
495 +#elif defined(_WIN32)
496 + pid_t const cpid = spawnvp(_P_NOWAIT, argv[0], &*argv.begin());
498 pid_t const cpid = ::fork();
502 << strerror(errno) << endl;
506 - pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
507 - argv[0], &*argv.begin());
511 Index: src/support/forkedcall.h
512 ===================================================================
513 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.h,v
514 retrieving revision 1.19
515 diff -u -r1.19 forkedcall.h
516 --- src/support/forkedcall.h 26 Sep 2004 14:19:47 -0000 1.19
517 +++ src/support/forkedcall.h 17 Jan 2005 12:17:09 -0000
520 #include <sys/types.h>
529 Index: src/support/forkedcontr.C
530 ===================================================================
531 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.C,v
532 retrieving revision 1.27
533 diff -u -r1.27 forkedcontr.C
534 --- src/support/forkedcontr.C 20 Jan 2005 15:38:14 -0000 1.27
535 +++ src/support/forkedcontr.C 21 Jan 2005 09:51:07 -0000
541 +#include "os_win32.h"
542 +#include <windows.h>
545 #include <boost/bind.hpp>
553 -#include <sys/wait.h>
555 +# include <sys/wait.h>
561 ForkedcallsController::Data & store =
562 fcc.reaped_children[++fcc.current_child];
563 // Clean up the child process.
565 store.pid = wait(&store.status);
570 @@ -193,11 +203,12 @@
571 ForkedcallsController::ForkedcallsController()
572 : reaped_children(50), current_child(-1)
575 signal(SIGCHLD, child_handler);
577 sigemptyset(&oldMask);
578 sigemptyset(&newMask);
579 sigaddset(&newMask, SIGCHLD);
585 // I want to print or something.
586 ForkedcallsController::~ForkedcallsController()
589 signal(SIGCHLD, SIG_DFL);
595 forkedCalls.push_back(newcall.clone());
597 if (forkedCalls.size() > reaped_children.size()) {
599 // Block the SIGCHLD signal.
600 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
604 // Unblock the SIGCHLD signal and restore the old mask.
605 sigprocmask(SIG_SETMASK, &oldMask, 0);
611 if (current_child == -1)
615 // Block the SIGCHLD signal.
616 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
619 for (int i = 0; i != 1 + current_child; ++i) {
620 Data & store = reaped_children[i];
626 // Unblock the SIGCHLD signal and restore the old mask.
627 sigprocmask(SIG_SETMASK, &oldMask, 0);
631 } // namespace support
632 Index: src/support/forkedcontr.h
633 ===================================================================
634 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.h,v
635 retrieving revision 1.18
636 diff -u -r1.18 forkedcontr.h
637 --- src/support/forkedcontr.h 7 Nov 2004 13:22:51 -0000 1.18
638 +++ src/support/forkedcontr.h 23 Jan 2005 12:25:33 -0000
640 #include <boost/shared_ptr.hpp>
643 -//#include <sys/types.h> // needed for pid_t
647 +#include <sys/types.h> // needed for pid_t
652 /// The child processes
653 ListType forkedCalls;
656 /// Used to block SIGCHLD signals.
657 sigset_t newMask, oldMask;
661 } // namespace support
662 Index: src/support/socktools.C
663 ===================================================================
664 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/socktools.C,v
665 retrieving revision 1.6
666 diff -u -r1.6 socktools.C
667 --- src/support/socktools.C 20 Jan 2005 15:38:14 -0000 1.6
668 +++ src/support/socktools.C 21 Jan 2005 09:43:42 -0000
674 #include <sys/socket.h>
681 // special file 'name' will be created in the filesystem.
682 int listen(string const & name, int queue)
685 int fd; // File descriptor for the socket
686 sockaddr_un addr; // Structure that hold the socket address
688 @@ -105,14 +108,17 @@
689 lyx::support::unlink(name);
699 // Returns a file descriptor for a new connection from the socket
700 // descriptor 'sd' (or -1 in case of error)
706 // Returns the new file descriptor or -1 in case of error
716 } // namespace socktools
717 Index: src/support/tempname.C
718 ===================================================================
719 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/tempname.C,v
720 retrieving revision 1.25
721 diff -u -r1.25 tempname.C
722 --- src/support/tempname.C 20 Jan 2005 15:38:14 -0000 1.25
723 +++ src/support/tempname.C 24 Jan 2005 07:51:08 -0000
725 # include <sys/stat.h>
732 using boost::scoped_array;
737 #if defined(HAVE_MKSTEMP)
738 return ::mkstemp(templ);
739 +#elif defined(_WIN32)
741 + return (int) ::fopen(templ, "w");
742 #elif defined(HAVE_MKTEMP)
743 // This probably just barely works...
747 string const tmpdir(dir.empty() ? package().temp_dir() : dir);
748 string tmpfl(AddName(tmpdir, mask));
750 tmpfl += convert<string>(getpid());
754 // The supposedly safe mkstemp version
756 int const tmpf = make_tempfile(tmpl.get());
758 string const t(tmpl.get());
760 + ::fclose((FILE *) tmpf);
764 lyxerr[Debug::FILES] << "Temporary file `" << t
765 << "' created." << endl;
767 Index: src/support/userinfo.C
768 ===================================================================
769 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/userinfo.C,v
770 retrieving revision 1.9
771 diff -u -r1.9 userinfo.C
772 --- src/support/userinfo.C 20 Jan 2005 15:38:14 -0000 1.9
773 +++ src/support/userinfo.C 21 Jan 2005 09:43:42 -0000
776 #include <boost/assert.hpp>
787 string const user_name()
790 struct passwd * pw(getpwuid(geteuid()));