× 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.



On Mon, 16 Jan 2006, Scott Klement wrote:

Actually I coded up an example that uses setitimer() and also avoids the
problem discussed in the paragraph above.  My example also uses signals to
terminate the program gracefully.  My example is in C but you could call
RPG subprocedures from the C code to do what you want.  My example is
here:
http://archive.midrange.com/c400-l/200511/msg00007.html

I don't see how your code solves the problems I discussed (aside from the
fact that all it does is print a message, and there's no way that could
take that long.

The problem it solves is that it will call the action() every time the timer goes off, even if action() takes longer to execute than the timer wait period. The action() function is where you would put your useful code.

Also, your code doesn't run on the iSeries -- at least not on my V5R3
system.  It crashes immediately with a floating point error, and never
even gets to the point of calling setitimer().

As the disclaimer said at the bottom of the example, "This has only been tested on linux, but should be cross platform..." I guess it isn't as cross platform as I hoped. Still, it is quite valuable as an example, and that is the whole point of posting it.

It also uses the signal() API which is slow because it saves the program
stack when it receives a signal and restores it when the signal handler
exits.  This behavior is annoying because it also means you can't use
global variables to communicate with your signal handler.

When you use the setitimer() function you can't help but use signals. setitimer uses signals as a trigger. I simply added another signal to shut down gracefully. If you use setitimer() at all, you will by necessity use signals (at least this is true on linux - if this isn't true on OS/400 then just say so).

I don't understand why you think a Linux C solution is an appropriate
answer for an iSeries RPG question.

Because the example is relevant to the post that setitimer() could solve the problem.

James Rich

It's not the software that's free; it's you.
        - billyskank on Groklaw

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.