Hi,
Es ist häufiger SIGTERM bei STRG+C, Kostet aber auch nix, beide zu überwachen.
Ja, ich gebe offen zu: das "häufiger" war eine offene Provokation ;-)
So? Ich habe mich daran gehalten: http://www.wlug.org.nz/SIGINT.
Ist kein internationales Standardorgan, interessiert also nicht die Bohne.
Aber ich erkläre mich auch gerne genauer: nicht nur, das es nur "meistens" SIGINT ist und auch nur "meistens" das Programm beendet so heißt das noch lange nichts. Das zur regulären Programmbeendung vorgesehene Signal ist nunmal SIGTERM.
so short
Christoph Zurnieden
PS: Zum probieren (autogeneriert aus der LIBC-Infodatei, blöderweise ist beim Ausprobieren mit STRG+D die History des kterms verlorengegangen, deshalb hier nur der generierte und daher recht längliche und sehr ungeschickt aussehende Code)
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
void sigprocint(){
puts("SIGINT sent.");
}
void sigprocfpe(){
puts("SIGFPE sent.");
}
void sigprocill(){
puts("SIGILL sent.");
}
void sigprocsegv(){
puts("SIGSEGV sent. How did you got this message?");
}
void sigprocbus(){
puts("SIGBUS sent.");
}
void sigproctrap(){
puts("SIGTRAP sent. What debugger are you using?");
}
void sigprociot(){
puts("SIGIOT sent. Oh, we're running on a PDP-11?");
}
void sigprocabrt(){
puts("SIGABRT sent.");
}
void sigprocemt(){
puts("SIGEMT sent. Not really, only emulated.");
}
void sigprocsys(){
puts("SIGSYS sent.");
}
void sigprocterm(){
puts("SIGTERM sent.");
}
void sigprocquit(){
puts("SIGQUIT sent.");
}
void sigprockill(){
puts("SIGKILL sent. How did you get _that_?");
}
void sigprochup(){
puts("SIGHUP sent.");
}
void sigprocalrm(){
puts("SIGALARM sent.");
}
void sigprocvtalrm(){
puts("SIGVTALRM sent.");
}
void sigprocprof(){
puts("SIGPROF sent.");
}
void sigprocio(){
puts("SIGIO sent.");
}
void sigprocurg(){
puts("SIGURG sent.");
}
void sigprocpoll(){
puts("SIGPOLL sent. SCO's greeting, they want their code back!");
}
void sigprocchld(){
puts("SIGCHLD sent.");
}
void sigproccld(){
puts("SIGCLD sent. Quit ol' system, hu?");
}
void sigproccont(){
puts("SIGCONT sent.");
}
void sigprocstop(){
puts("SIGSTOP sent. Hu?");
}
void sigprocstp(){
puts("SIGSTP sent.");
}
void sigprocttin(){
puts("SIGTTIN sent.");
}
void sigprocttou(){
puts("SIGTTOU sent.");
}
void sigprocpipe(){
puts("SIGTPIPE sent.");
}
void sigproclost(){
puts("SIGTLOST sent.");
}
void sigprocxcpu(){
puts("SIGTXCPU sent. Please resist nethack");
}
void sigprocxfsz(){
puts("SIGTXFSZ sent. To much pr0n on device.");
}
void sigprocusr1(){
puts("SIGTUSR1 sent.");
}
void sigprocusr2(){
puts("SIGTUSR2 sent.");
}
void sigprocwinch(){
puts("SIGTWINCH sent.");
}
void sigprocinfo(){
puts("SIGTINFO sent.");
}
int main(){
signal(SIGINT,sigprocint);
signal(SIGFPE,sigprocfpe);
signal(SIGILL,sigprocill);
signal(SIGSEGV,sigprocsegv);
signal(SIGBUS,sigprocbus);
signal(SIGTRAP,sigproctrap);
signal(SIGIOT,sigprociot);
signal(SIGABRT,sigprocabrt);
#ifdef SIGEMT
signal(SIGEMT,sigprocemt);
#endif
signal(SIGSYS,sigprocsys);
signal(SIGSYS,sigprocsys);
signal(SIGTERM,sigprocterm);
signal(SIGINT,sigprocint);
signal(SIGQUIT,sigprocquit);
signal(SIGKILL,sigprockill);
signal(SIGHUP,sigprochup);
signal(SIGALRM,sigprocalrm);
signal(SIGVTALRM,sigprocvtalrm);
signal(SIGPROF,sigprocprof);
signal(SIGIO,sigprocio);
signal(SIGURG,sigprocurg);
signal(SIGPOLL,sigprocpoll);
signal(SIGCHLD,sigprocchld);
signal(SIGCLD,sigproccld);
signal(SIGCONT,sigproccont);
signal(SIGSTOP,sigprocstop);
#ifdef SIGSTP
signal(SIGSTP,sigprocstp);
#endif
signal(SIGTTIN,sigprocttin);
signal(SIGTTIN,sigprocttin);
signal(SIGTTOU,sigprocttou);
signal(SIGPIPE,sigprocpipe);
#ifdef SIGLOST
signal(SIGLOST,sigproclost);
#endif
signal(SIGXCPU,sigprocxcpu);
signal(SIGXFSZ,sigprocxfsz);
signal(SIGUSR1,sigprocusr1);
signal(SIGUSR2,sigprocusr2);
signal(SIGWINCH,sigprocwinch);
#ifdef SIGINFO
signal(SIGINFO,sigprocinfo);
#endif
printf("Send SIGKILL to PID %d to end this program,\
any other signal might be caught and printed.\n\n", getpid());
for(;;)
pause();
exit(EXIT_SUCCESS);
}
CZ