[slang-users] need to send signals two times
John E. Davis
davis at space.mit.edu
Sun Apr 29 15:35:20 EDT 2007
Here is version of your script that uses open/close:
# slsh /tmp/foo.sl
before open -- press ^C
got signal 2
caught SignalError
removing fifo
% foo.sl
variable quit = 0;
new_exception ("SignalError", RunTimeError, "Signal Error");
define sig_handler(sig)
{
quit++;
message("got signal $sig"$);
throw SignalError;
}
define slsh_main ()
{
signal(SIGHUP, &sig_handler);
signal(SIGINT, &sig_handler);
signal(SIGQUIT, &sig_handler);
variable fifo_name = "/tmp/jed.latex." + string(getpid());
if (mkfifo(fifo_name, 0600) != 0)
throw ApplicationError, "Could not create FIFO";
try
{
message("before open -- press ^C");
variable fifo = open(fifo_name, O_RDONLY);
message("after open");
if (quit)
{
message ("quit=$quit, fifo=$fifo"$);
if (fifo != NULL)
()=close(fifo);
break;
}
}
catch SignalError: message ("caught SignalError");
finally
{
message ("removing fifo");
() = remove(fifo_name);
}
}
More information about the slang-users-l
mailing list