| version 1.5, 2002/02/25 18:45:53 |
version 1.6, 2002/04/09 21:16:45 |
|
|
| #include "sigserv.h" |
#include "sigserv.h" |
| #include "message.h" |
#include "message.h" |
| |
|
| //static int wait_for_child(PROCTABLE *p_ptbl); |
#if 0 |
| |
|
| static RETSIGTYPE |
static RETSIGTYPE |
| sigserv_sigaction(sig, info, unused) |
sigserv_sigaction(sig, info, unused) |
| Line 60 sigserv_sigaction(sig, info, unused) |
|
| Line 60 sigserv_sigaction(sig, info, unused) |
|
| } |
} |
| } |
} |
| switch (info->si_code) { |
switch (info->si_code) { |
| case CLD_EXITED: // | child has exited | |
case CLD_EXITED: /* | child has exited | */ |
| msg_print("SIGCHLD -- child %d exited " |
msg_print("SIGCHLD -- child %d exited " |
| "with status %d (%s)\n", |
"with status %d (%s)\n", |
| info->si_pid, |
info->si_pid, |
| info->si_errno, |
info->si_errno, |
| strerror(info->si_errno)); |
strerror(info->si_errno)); |
| break; |
break; |
| case CLD_KILLED: // | child was killed | |
case CLD_KILLED: /* | child was killed | */ |
| msg_print("SIGCHLD -- child %d was killed" |
msg_print("SIGCHLD -- child %d was killed" |
| "by signal %d (%s)\n", |
"by signal %d (%s)\n", |
| info->si_pid, |
info->si_pid, |
| info->si_signo, |
info->si_signo, |
| strerror(info->si_errno)); |
strerror(info->si_errno)); |
| break; |
break; |
| case CLD_DUMPED: // | child terminated abnormally | |
case CLD_DUMPED: /* | child terminated abnormally | */ |
| msg_print("SIGCHLD -- child %d terminated abnormaly" |
msg_print("SIGCHLD -- child %d terminated abnormaly" |
| "by signal %d (%s)\n", |
"by signal %d (%s)\n", |
| info->si_pid, |
info->si_pid, |
| info->si_signo, |
info->si_signo, |
| strerror(info->si_errno)); |
strerror(info->si_errno)); |
| break; |
break; |
| case CLD_TRAPPED: // | traced child has trapped | |
case CLD_TRAPPED: /* | traced child has trapped | */ |
| break; |
break; |
| case CLD_STOPPED: // | child has stopped | |
case CLD_STOPPED: /* | child has stopped | */ |
| break; |
break; |
| case CLD_CONTINUED: // | stopped child has continued | |
case CLD_CONTINUED: /* | stopped child has continued | */ |
| break; |
break; |
| } |
} |
| |
|
| Line 119 sigserv_init(ptbl) |
|
| Line 119 sigserv_init(ptbl) |
|
| sigaction(SIGINT, &sa, NULL); |
sigaction(SIGINT, &sa, NULL); |
| sigaction(SIGPIPE, &sa, NULL); |
sigaction(SIGPIPE, &sa, NULL); |
| */ |
*/ |
| |
/* |
| signal(SIGCHLD, sigserv_sigaction); |
signal(SIGCHLD, sigserv_sigaction); |
| //signal(SIGINT, sigserv_sigaction); |
signal(SIGINT, sigserv_sigaction); |
| |
*/ |
| /* toto je zoznam vsetkych signalov ktore existuju |
/* toto je zoznam vsetkych signalov ktore existuju |
| * moze to ist prec, len som skusal vo ^d, ale |
* moze to ist prec, len som skusal vo ^d, ale |
| * ziadny signal vredy ep nedostava |
* ziadny signal vredy ep nedostava |
| * |
*/ |
| |
/* |
| signal(SIGQUIT , sigserv_sigaction); |
signal(SIGQUIT , sigserv_sigaction); |
| signal(SIGILL , sigserv_sigaction); |
signal(SIGILL , sigserv_sigaction); |
| signal(SIGABRT , sigserv_sigaction); |
signal(SIGABRT , sigserv_sigaction); |
| Line 162 sigserv_init(ptbl) |
|
| Line 164 sigserv_init(ptbl) |
|
| */ |
*/ |
| } |
} |
| |
|
| |
#endif |
| |
|
| /* |
|
| * Function wait for parent's child, print status of exited child |
|
| * and command line of childs process. |
|
| */ |
|
| // static int |
|
| //wait_for_child(p_ptbl) |
|
| // PROCTABLE *p_ptbl; |
|
| //{ |
|
| // register int who, index; |
|
| // int status; |
|
| // |
|
| // who = wait(&status); |
|
| // /* |
|
| // * RETURN VALUE |
|
| // * The process ID of the child which exited, -1 on error or |
|
| // * zero if WNOHANG was used and no child was available (in |
|
| // * which case, errno is set to an appropriate value). |
|
| // */ |
|
| // |
|
| //#if DEBUG |
|
| // msg_debug_print("wait_for_child(): who = %d, status = %d\n", who, status); |
|
| //#endif |
|
| // |
|
| // switch (who) { |
|
| // case -1: |
|
| // msg_error_print("wait4child(): wait() = %d\n", who); |
|
| // /* podla mna sa aj tuto nastavuje nejake cislo chyby, preto |
|
| // * aj tu treba spravit switch (errno) {} a nejako to osetrovat |
|
| // */ |
|
| // exit(1); |
|
| // break; |
|
| // case 0: |
|
| // switch (errno) { |
|
| // case ECHILD: |
|
| // msg_error_print("no child process, terminating...\n"); |
|
| // exit(0); /* TODO */ |
|
| // break; |
|
| // default: |
|
| // break; |
|
| // } |
|
| // break; |
|
| // |
|
| // default: |
|
| // |
|
| // /* Normal exit? */ |
|
| // if ((status&0377) == 0) |
|
| // msg_debug_print("[%d] [exit %.2d] ", who, status); |
|
| // else |
|
| // msg_debug_print("[%d] [signal %.2d] ", who, status & 0177); |
|
| // |
|
| // index = proctable_get_process_index_by_pid((*p_ptbl), who); |
|
| // |
|
| // if (index == -1) { |
|
| // msg_print("\n"); |
|
| // msg_error_print("wait_for_child(): " |
|
| // "inconsistency of process table " |
|
| // "(no such process with PID %d)\n", who); |
|
| // exit(1); /* TODO */ |
|
| // } |
|
| // else { |
|
| // process_print_cmdline((*p_ptbl)[index]); |
|
| // msg_print("\n"); |
|
| // |
|
| // if (proctable_remove_process(p_ptbl, index) == -1) { |
|
| // msg_error_print( |
|
| // "error removing process from process table\n"); |
|
| // exit(1); /* TODO */ |
|
| // } |
|
| // else |
|
| //#if DEBUG |
|
| // msg_debug_print("wait_for_child(): process removed " |
|
| // "(index = %d, PID = %d)\n", index, who); |
|
| //#endif |
|
| // |
|
| // return 1; |
|
| // } |
|
| // |
|
| // break; |
|
| // } |
|
| // |
|
| // return 0; |
|
| //} |
|
| // |
|
| // |
|