Changeset 68456fa for tests/meta
- Timestamp:
- Oct 10, 2022, 2:47:35 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- fd90096
- Parents:
- affb51b
- Location:
- tests/meta
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/meta/fork+exec.cfa
raffb51b r68456fa 13 13 // Update Count : 14 14 // 15 #include <stdlib.h>16 #include <stdio.h>17 #include <string.h>18 15 19 #include <errno.h> 20 #include <signal.h> 21 22 extern "C" { 23 #include <sys/types.h> 24 #include <sys/wait.h> 25 #include <unistd.h> 26 } 27 28 int true_main(const char * exec); 16 #include "fork+exec.hfa" 29 17 30 18 int main(int argc, char * argv[]) { 31 if(!getenv("CFATEST_FORK_EXEC_TEXT")) return true_main(argv[0]);19 check_main(argv[0]); 32 20 33 21 printf("arguments are:\n"); … … 42 30 } 43 31 44 int do_wait(pid_t pid) {45 int wstatus;46 int options = 0;47 pid_t ret = waitpid(pid, &wstatus, options);48 fflush(stdout);49 if(ret < 0) {50 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno));51 exit(1);52 }53 return wstatus;54 }55 32 56 pid_t strict_fork(void) {57 fflush(stdout);58 pid_t ret = fork();59 if(ret < 0) {60 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno));61 exit(1);62 }63 return ret;64 }65 33 66 void print_status(int wstatus) { 67 printf("Child status:\n"); 68 printf(" WIFEXITED : %d\n", WIFEXITED(wstatus)); 69 printf(" WEXITSTATUS : %d\n", WEXITSTATUS(wstatus)); 70 printf(" WIFSIGNALED : %d\n", WIFSIGNALED(wstatus)); 71 printf(" WTERMSIG : %d\n", WTERMSIG(wstatus)); 72 printf(" WCOREDUMP : %d\n", WCOREDUMP(wstatus)); 73 printf(" WIFSTOPPED : %d\n", WIFSTOPPED(wstatus)); 74 printf(" WSTOPSIG : %d\n", WSTOPSIG(wstatus)); 75 printf(" WIFCONTINUED: %d\n", WIFCONTINUED(wstatus)); 76 } 77 78 int true_main(const char * path) { 79 char * env[] = { "CFATEST_FORK_EXEC_TEXT=1", 0p }; 80 34 int true_main(const char * path, char * env[]) { 81 35 printf("no arg:\n"); 82 36 if(pid_t child = strict_fork(); child == 0) {
Note: See TracChangeset
for help on using the changeset viewer.