c - the child process exited normally even if I sent a SIGABRT to it -
i trying process operations fork()ing , exec()ing tried example in parent wait()s child return , test if child ended (by exit()ing or return caller) or abnormally (receiving signal sigabrt)
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<unistd.h> #include <sys/wait.h> int spawn (char* program, char** arg_list) { pid_t child_pid; child_pid = fork (); if (child_pid != 0) return child_pid; else { execvp (program, arg_list); abort(); } } int main () { int child_status; char* arg_list[] = {"ls","/",null}; spawn ("ls", arg_list); wait (&child_status); if (wifexited (child_status)) printf ("the child process exited normally, exit code %d\n", wexitstatus (child_status)); else printf ("the child process exited abnormally\n"); return 0; }
i expect see sentence"the child process exited abnormally" saw "the child process exited normally, exit code 0"!!! if child ended calling abort() send sigabrt help? in advance
when call functions in exec()
family executing program replaced 1 specified in call exec()
. means there never call abort()
. ls program runs completeion exits normally.
Comments
Post a Comment