ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.44 by root, Fri Nov 2 20:59:14 2007 UTC vs.
Revision 1.46 by root, Sat Nov 3 09:20:12 2007 UTC

42#include <stdio.h> 42#include <stdio.h>
43 43
44#include <assert.h> 44#include <assert.h>
45#include <errno.h> 45#include <errno.h>
46#include <sys/types.h> 46#include <sys/types.h>
47#ifndef WIN32
47#include <sys/wait.h> 48# include <sys/wait.h>
49#endif
48#include <sys/time.h> 50#include <sys/time.h>
49#include <time.h> 51#include <time.h>
50 52
51/**/ 53/**/
52 54
438} 440}
439 441
440static void 442static void
441siginit (void) 443siginit (void)
442{ 444{
445#ifndef WIN32
443 fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC); 446 fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC);
444 fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC); 447 fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC);
445 448
446 /* rather than sort out wether we really need nb, set it */ 449 /* rather than sort out wether we really need nb, set it */
447 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK); 450 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
448 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK); 451 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
452#endif
449 453
450 ev_io_set (&sigev, sigpipe [0], EV_READ); 454 ev_io_set (&sigev, sigpipe [0], EV_READ);
451 ev_io_start (&sigev); 455 ev_io_start (&sigev);
452} 456}
453 457
464 468
465/*****************************************************************************/ 469/*****************************************************************************/
466 470
467static struct ev_child *childs [PID_HASHSIZE]; 471static struct ev_child *childs [PID_HASHSIZE];
468static struct ev_signal childev; 472static struct ev_signal childev;
473
474#ifndef WIN32
469 475
470#ifndef WCONTINUED 476#ifndef WCONTINUED
471# define WCONTINUED 0 477# define WCONTINUED 0
472#endif 478#endif
473 479
479 485
480 while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1) 486 while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1)
481 for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next) 487 for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next)
482 if (w->pid == pid || !w->pid) 488 if (w->pid == pid || !w->pid)
483 { 489 {
490 w->rpid = pid;
484 w->status = status; 491 w->rstatus = status;
485 event ((W)w, EV_CHILD); 492 event ((W)w, EV_CHILD);
486 } 493 }
487} 494}
495
496#endif
488 497
489/*****************************************************************************/ 498/*****************************************************************************/
490 499
491#if EV_USE_KQUEUE 500#if EV_USE_KQUEUE
492# include "ev_kqueue.c" 501# include "ev_kqueue.c"
564 if (ev_method) 573 if (ev_method)
565 { 574 {
566 ev_watcher_init (&sigev, sigcb); 575 ev_watcher_init (&sigev, sigcb);
567 siginit (); 576 siginit ();
568 577
578#ifndef WIN32
569 ev_signal_init (&childev, childcb, SIGCHLD); 579 ev_signal_init (&childev, childcb, SIGCHLD);
570 ev_signal_start (&childev); 580 ev_signal_start (&childev);
581#endif
571 } 582 }
572 } 583 }
573 584
574 return ev_method; 585 return ev_method;
575} 586}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines