[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sequential background tasks

On 07/17/2006 03:59 AM, T wrote:
{ task-a ; task-b ; } &

to avoid needlessly forking.
This is the common theme for all the answers so far. But the problem is
that my background tasks are real background tasks, eg. emacs and tk
scripts, that they'd not finish and return.
So I guess that I have to rely on longer sleeping then?

Some years ago, I had to solve a problem like this, and my solution was "done-files." I was writing a system programs that relied on each others input. Platform constraints that I can't remember obliged me to start all three programs asynchronously, so I made each program write a file name of <program>-done.$$$ upon finishing.

For example, if the programs were named stage1, stage2 and stage3; stage1 would create a zero-byte file named stage1-done.$$$, and stage2 would write stage2-done.$$$ when it was finished. Stage3 didn't need to write a "done-file."

Stage2 would wait for stage1-done.$$$ to appear before doing anything, and stage3 would wait for stage2-done.$$$ before doing anything. So I was able to get three asynchronously run programs to act synchronously.


Reply to: