- Subject: Re: [slang-users] need to send signals two times
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 15:35:20 -0400
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);
}
}
[2007 date index]
[2007 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]