1 /* wait.cc: Posix wait routines.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
16 /* This is called _wait and not wait because the real wait is defined
17 in libc/syscalls/syswait.c. It calls us. */
22 return wait4 (-1, status
, 0, NULL
);
26 waitpid (pid_t intpid
, int *status
, int options
)
28 return wait4 (intpid
, status
, options
, NULL
);
32 wait3 (int *status
, int options
, struct rusage
*r
)
34 return wait4 (-1, status
, options
, r
);
37 /* Wait for any child to complete.
38 * Note: this is not thread safe. Use of wait in multiple threads will
43 wait4 (int intpid
, int *status
, int options
, struct rusage
*r
)
47 waitq
*w
= &_my_tls
.wq
;
49 pthread_testcancel ();
53 sig_dispatch_pending ();
54 if (options
& ~(WNOHANG
| WUNTRACED
| WCONTINUED
))
62 memset (r
, 0, sizeof (*r
));
67 sigproc_printf ("calling proc_subproc, pid %d, options %d",
69 if (!proc_subproc (PROC_WAIT
, (uintptr_t) w
))
72 paranoid_printf ("proc_subproc returned 0");
77 if ((waitfor
= w
->ev
) == NULL
)
80 res
= cygwait (waitfor
, cw_infinite
, cw_cancel
| cw_cancel_self
);
82 sigproc_printf ("%d = cygwait (...)", res
);
87 /* found no children */
95 if (_my_tls
.call_signal_handler ())
97 set_sig_errno (EINTR
);
100 else if (res
!= WAIT_OBJECT_0
)
105 else if ((res
= w
->pid
) != 0 && status
)
110 syscall_printf ("%R = wait4(%d, %y, %d, %p)", res
, intpid
, w
->status
, options
, r
);