catching system signals from C code

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, I’m writing a program that need to catch some system signals…


#include many things

void sig_handler (int);
void clean (parameters);

int main () {
struct sigaction new_action;

new_action.sa_handler = sig_handler;
new_action.sa_flags = 0;
sigemptyset(&new_action.sa_mask);

sigaction(SIGINT,  &new_action, NULL);
sigaction(SIGSEGV, &new_action, NULL);
sigaction(SIGPIPE, &new_action, NULL);
sigaction(SIGTERM, &new_action, NULL);
sigaction(SIGCHLD, &new_action, NULL);

declaration of variables;
while (expresion) {
} // while

clean();
return 0;
} // main

void sig_handler (int signum) {
/* HERE */
exit(signum);
} // sig_handler

void clean (parameters) {
some code here;
} // clean


so, on the function sig_handler where the comment /* HERE */ is… is
there any way to call the function clean, because I have to use
parameters declared inside the main function


VampirD

Microsoft Windows is like air conditioning
Stops working when you open a window.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iEYEARECAAYFAkzkAMgACgkQJQ+0ABWtaVl66QCg0SNoUztf1gKnEXHhRaoT6ukK
qQAAoLQrdc9r0uLpPA7xEOpDigvdzGx4
=moDS
-----END PGP SIGNATURE-----

You can access global variables, but not variables in function scope.

After a few years improving my JS code, I think is time to learn some hi-levels languages to have a big range of vision!!

C sintax is so close to JS,I will begin with C, and maybe fix some problems in future, and send solutions to Linus!! lololo