[erlang-questions] signal handler

Saifi Khan saifi@REDACTED
Tue Jun 5 06:57:29 CEST 2007


Hi:

How does one write a signal handler in erlang ?

I want to convert the following C code to Erlang:

#include <stdio.h>
#include <stdlib.h>
#include <sys/unistd.h>
#include <signal.h>

void ctrlc_handler(int sig)
{
	char c;

	signal(sig, SIG_IGN);

	printf("ctrlc-handler called\n");

	printf("do you want to exit[y/n] ");
	c = getchar();

	if (c == 'y' || c == 'Y')
		exit(0);
	else
		signal(SIGINT, ctrlc_handler);
}


int main(int argc, char *argv[])
{
	signal(SIGINT, ctrlc_handler);

	while (1)
		pause();

	return 0;
}

In the signal handler function 'ctrlc-handler',
all the SIGINT signals that occur between the two signal calls
cannot be caught. Is this semantics carried over in Erlang as well ?


Thanks in advance.

thanks
Saifi.


TWINCLING Society
freedom of innovation
http://www.twincling.org/



More information about the erlang-questions mailing list