× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have a piece of RPG code that is running as part of a C program. The code
is critical code and only one thread at a time can execute it.

I sendmsg and recvmsg to send message between two job.

All works perfectly if that other job is still there but when that job dies
or crashes and I attempt to a recvmsg, it hangs forever.

To avoid that problem, I am using signals Scott has discussed.

I enable the signals and then issue an alarm before I issue the recvmsg.

If I use 1 second and their is nothing out there I would expect for the
recvmsg to hang which it does but the alarm never fires.

I am trying to figure out why the alarm is not firing. Is it possible the
alarm doesn't work because the RPG code was called from a thread in C code?

I just tired some test code that had one program spawn another program and
I did an alarm in that job and it worked so that tells me that the fact
that I am running in a multi-threaded environment must be what is causing
the problem.

I am using Thread(*SERIALIZE) for the RPG module.

Any help would be appreciated.

Qp0sEnableSignals();
sigemptyset(act.sa_mask);
sigaddset(act.sa_mask: SIGALRM);
act.sa_handler = %paddr(GotAlarm);
act.sa_flags = 0;
act.sa_sigaction = *NULL;
sigaction(SIGALRM: act: *omit);

0151.00 Alarm(InTimeout);
0152.00 If RecvMsgApi(InSocket:MsgHdr:0) < 0;
0153.00 GetLastError(ErrorNumber:
0154.00 Msg);
0155.00 Qp0sDisableSignals();
0156.00 If ErrorNumber = EINTR;
0157.00 %Len(Msg) = 0;
0158.00 Return Msg;
0159.00 EndIf;
0160.00

dcl-proc GotAlarm;

dcl-pi *N;

InSignalNumber Int(10) Value;

end-Pi;



// Do nothing. The API will return EINTER("interrupted by signal")
when
// the signal is received.



end-proc;

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.