Mail Archives: cygwin/2009/07/10/06:25:17
--------------090306050707070807080301
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Reini Urban wrote:
> Any volunteer for WCONTINUED, WIFCONTINUED() for wait4() for the
> initial cygwin-1.7 release?
> See http://www.opengroup.org/onlinepubs/009695399/functions/wait.html
>
> Sorry, I'm not able to write this, but I have looked into wait.cc.
? They appear to exist and work. See "/usr/include/cygwin/wait.h".
Attached: crude smoketest derived from the opengroup web page linked above.
cheers,
DaveK
--------------090306050707070807080301
Content-Type: text/plain;
name="w4.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="w4.c"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main (int argc, const char **argv)
{
pid_t child_pid, wpid;
int status;
child_pid = fork();
if (child_pid == -1) { /* fork() failed */
perror("fork");
exit(EXIT_FAILURE);
}
if (child_pid == 0) { /* This is the child */
/* Child does some work and then terminates */
printf ("In child!\n");
fflush (0);
/* TRY WITH OR WITHOUT THIS LINE. */
* (int * ) 0 = 0;
/* TRY CHANGING THIS VALUE. */
return 42;
} else { /* This is the parent */
do {
wpid = waitpid(child_pid, &status, WUNTRACED
#ifdef WCONTINUED /* Not all implementations support this */
| WCONTINUED
#endif
);
if (wpid == -1) {
perror("waitpid");
exit(EXIT_FAILURE);
}
if (WIFEXITED(status)) {
printf("child exited, status=%d\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
printf("child killed (signal %d)\n", WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
printf("child stopped (signal %d)\n", WSTOPSIG(status));
#ifdef WIFCONTINUED /* Not all implementations support this */
} else if (WIFCONTINUED(status)) {
printf("child continued\n");
#endif
} else { /* Non-standard case -- may never happen */
printf("Unexpected status (0x%x)\n", status);
}
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
}
return 0;
}
--------------090306050707070807080301
Content-Type: text/plain; charset=us-ascii
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
--------------090306050707070807080301--
- Raw text -