|
From: Karl O. P. <ko...@me...> - 2012-12-06 17:07:58
|
On 11/16/2012 02:30:53 PM, Allen S. Rout wrote:
> On 11/16/2012 03:25 PM, Karl O. Pinc wrote:
>
>
> > To avoid the race condition the following needs to happen:
> > Establish wait.
> > Then finish sending data from script A to script B.
>
> Exactly; Establish the wait, finish what you're doing, and then act
> on
> the output.
>
> In perl idiom:
>
> $foo = new FileHandle("inotifywait -whateveroptions |");
>
> &Finish_sending_data();
>
> and then wait for inotify's output.
FYI. The problem with this is that it depends on the OS
scheduler. I'm using shell, and had an instance where
the race condition exhibited itself because the backgrounded
inotifywait had not yet established the wait when,
for whatever reason, the &Finish_sending_data(); step
had already finished.
I was able to make my problem go away, for all practical
purposes, by backrounding inotifywait earlier in the process.
The only way to ensure that the race condition does not happen
is to have inotifywait execute the &Finish_sending_data(); step,
because inotifywait is the only process that knows for sure
that the wait is established. To me, that means adding
an argument to inotifywait similar to su's -c argument.
Regards,
Karl <ko...@me...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
|