Changeset View
Changeset View
Standalone View
Standalone View
b/tests/t-fork.c
/* t-mutex.c | |||||
* Copyright 2011, 2012 g10 Code GmbH | |||||
* | |||||
* This file is free software; as a special exception the author gives | |||||
* unlimited permission to copy and/or distribute it, with or without | |||||
* modifications, as long as this notice is preserved. | |||||
* | |||||
* This file is distributed in the hope that it will be useful, but | |||||
* WITHOUT ANY WARRANTY, to the extent permitted by law; without even the | |||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |||||
*/ | |||||
#include "t-support.h" | |||||
int | |||||
main (int argc, char *argv[]) | |||||
{ | |||||
int rc; | |||||
rc = npth_init (); | |||||
fail_if_err (rc); | |||||
npth_unprotect (); | |||||
npth_protect (); | |||||
pid_t pid; | |||||
npth_sigev_init (); | |||||
npth_sigev_add (SIGHUP); | |||||
npth_sigev_fini (); | |||||
pid = fork (); | |||||
if (pid == (pid_t)-1) | |||||
{ | |||||
fail_msg ("fork failed"); | |||||
exit (1); | |||||
} | |||||
else if (pid) | |||||
{ | |||||
int status; | |||||
info_msg("forked"); | |||||
waitpid(-1,&status,0); | |||||
if(status) { | |||||
exit(1); | |||||
} | |||||
} else { | |||||
npth_unprotect (); | |||||
info_msg("child exit"); | |||||
exit(0); | |||||
} | |||||
return 0; | |||||
} |