static void handle_signal(int sig) { debug(D_DEBUG, "received signal %d: %s", sig, string_signal(sig)); switch (sig) { case SIGINT: case SIGTERM: case SIGQUIT: want_to_exit = 1; break; case SIGHUP: change_state(STATE_STOP_WAIT); break; } }
static int process_status( const char *name, pid_t pid, int status, int line ) { int result=0; if(WIFEXITED(status)) { int code = WEXITSTATUS(status); if(code==0) { ftsh_error(FTSH_ERROR_PROCESS,line,"%s [%d] exited normally with status %d",name,pid,code); result = 1; } else { ftsh_error(FTSH_ERROR_FAILURE,line,"%s [%d] exited normally status with %d",name,pid,code); result = 0; } } else if(WIFSIGNALED(status)) { int sig = WSTOPSIG(status); ftsh_error(FTSH_ERROR_FAILURE,line,"%s [%d] exited abnormally with signal %d (%s)",name,pid,sig,string_signal(sig)); result = 0; } else { ftsh_error(FTSH_ERROR_FAILURE,line,"%s [%d] exited for unknown reasons (wait status %d)",name,pid,status); result = 0; } return result; }