From: john@comet.msd.measurex.com (John Pletikapich)
Subject: Signal Handling in OSF/1 v3.0B
Date: 1995/05/30 [thread overview]
Message-ID: <1995May30.195936.14140@msd.measurex.com> (raw)
I have some C code which is operational under Ultrix v2.2 and I was
hoping I could get it working on OSF/1 V3.0B . The code was fairly
basic - read a tty and timeout if no input is given. I replaced the Ultrix
signal function with the OSF/1 sigaction syscall, but have not made
any headway. The ALARM signal is deferred once , but seemingly
ingnored the second time around, i.e. No Timeout! I have checked all
statuses (stati) that I could think of but I can't see what's going
wraong. I have included a snippet of the code below and would
appreciate any intelligent advice anyone can offer.
One thousand thanks!
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include <sgtty.h>
#include <sys/file.h>
#include <sys/ioctl.h>
jmp_buf jump_alrm;
read_robo()
{
char c;
int red;
int len;
int j;
int jjpstat;
struct sigaction newaction, saveaction, jjpaction;
void _catch();
unsigned int save_time;
for (;;)
{
if (setjmp(jump_alrm))
{
jjpstat = sigaction(SIGALRM, &saveaction, 0);
if (save_time)
alarm((unsigned int)(j = save_time - 10) < 0 ? 1 : j);
return(3);
}
newaction.sa_handler = _catch;
newaction.sa_mask = 0;
newaction.sa_flags = 0;
jjpstat = sigaction(SIGALRM, &newaction, &saveaction);
save_time = alarm((unsigned int)15);
red = read(rt, &c, 1);
jjpstat = sigaction(SIGALRM, &saveaction, 0);
if (save_time)
alarm((unsigned int)(j = save_time - 10) < 0 ? 1 : j);
else
alarm((unsigned int)0);
if (red < 1)
{
return(2); /* code deleted for brevity */
}
process_it(); /* code deleted for brevity */
}
}
void
_catch()
{
longjmp(jump_alrm, 1);
}
--
john.msd.measurex.com John J. Pletikapich
reply other threads:[~1995-05-30 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox