Background processees

Please don't drum me out for being a COBOL programmer...but I'm in a bind right now. We wish to wean ourselves from having tasks started by cron, so I'm writing a series of COBOL programs that will initiate these tasks instead.

The intent is to have a master initiator running all the time in the background. It sleeps for 10 minutes, and then checks to make sure that all of the individual initiators are running. If the master initiator finds one not running, it will restart it. Once it has verified that all the individual initiators are running, it sleeps for 10 minutes, and starts the checking process again after it wakes up.

Each of these individual initiators, also running in the background, will check for the existance of a data file; if the file is found it will perform a specific task and delete the file. The initiator program will then sleep for for 5 minutes, wake up, check for the file again, run the task if the file is present, etc.

The master initiator is running in the background, and each of the individual initiators started by the master initiator is also running in the background.

My problem is that the individual initiator programs aren't always waking up, and there is no discernable pattern.

Sometimes the individual initiator program will sleep the first time, and not wake up. Other times it will sleep, wake up, check for the file, sleep, etc., for 5 or 6 complete cycles; but eventually it won't wake up, and the master initiator has to restart it again.

And when I say the individual initiator "doesn't wake up", the task actually terminates.

Anyone out there able to provide me with any guidance or assistance?

Thanks.

Comments

Re:Background processees

Are you issuing the system call "sleep" from inside your program?

Generally system calls are not good practice but only done in the case of extreme need. If you really want to sleep in C or C++ you would use the usleep() function. I don't know COBOL, so I doubt I can help you much, but is there an intrinsic sleep function in COBOL?

Perhaps look at this thread?
http://www.talkroot.com/archivee/index.php/t-65038_How_to_let_a_COBOL_program_sleep_5_seconds.html

Re:Background processees

Thanks for the suggestion, Dave. I've had others suggest the same thing, and I might give it a try if nothing else works. Never done anything in C before, but this might be as good a time as any to learn it.

Through a LOT of trial and error, I have been able to figure out that when you have a MicroFocus COBOL program running in background, and issue a UNIX sleep command, the program stops rather than going to sleep. It looks just like you pressed CTRL-Z.

When I run the program from a command prompt and don't specify & to put it into background, everything works fine. But when I run that same program from a command prompt with the &, the program stops.

Ray

Re: Background processees

Sounds like a perfet match for coding it using C and Threads?