<p dir="ltr">Also <a href="http://perldoc.perl.org/functions/system.html">http://perldoc.perl.org/functions/system.html</a> suggests using backticks to get output rather than system.</p>
<div class="gmail_quote">On 2014-02-01 4:15 PM, "Robert Keizer" <<a href="mailto:robert@keizer.ca">robert@keizer.ca</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">I would write a small test case in bash. Not hating on perl, but if it also exhibits those symptoms, rules perl out completely.</p>
<p dir="ltr">Also post bash script if you do end up doing this -I wouldn't mind taking a stab at it.</p>
<p dir="ltr">What file system are you using?</p>
<p dir="ltr">You could run strace on process-file which should tell you if it is indeed doing something funny.. </p>
<p dir="ltr">My guess is perl specific; I'd test without it and replicate.</p>
<p dir="ltr">Rob</p>
<div class="gmail_quote">On 2014-02-01 3:10 PM, "Trevor Cordes" <<a href="mailto:trevor@tecnopolis.ca" target="_blank">trevor@tecnopolis.ca</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm running into a strange race condition, that appears to me to be a<br>
Linux bug of some sort.<br>
<br>
I'm doing, perl pseudocode:<br>
<br>
system "process-file outputfileprefix"<br>
# does work and puts it in files named outputfileprefix-0, outputfileprefix-1, etc<br>
<br>
sleep 1;<br>
if (!<outputfileprefix-[0-9]*>) {<br>
warn "try #2\n";<br>
sleep 2;<br>
if (!<outputfileprefix-[0-9]*>) {<br>
warn "try #3\n";<br>
die;<br>
}<br>
}<br>
<br>
# do something on outputfile*<br>
<br>
For those that don't know <> is perl's glob op, which simply returns an<br>
array of all the files matching the glob. !<> is thus true if no files<br>
match the glob.<br>
<br>
What is happening is that 10-30% of the time, I get a "try #2" output. I<br>
haven't yet seen a try #3. Of course, having those retries (and sleeps)<br>
in there at all should not be required: I had to add them as I was seeing<br>
this program blow up in unexpected ways.<br>
<br>
process-file does not do anything async'ly, AFAIK. The final thing it<br>
does, the output that I need, is use the GD library to write a png file.<br>
Only after that does process-file exit. There are no threads or forks,<br>
unless GD is doing one, but even then the mini-program above should not<br>
return from system until all threads and (non-daemonized) forks are done.<br>
<br>
It appears the problem is process-file writes and closes a file, returns,<br>
yet the directory entry doesn't become visible to the calling script for 0<br>
to 3 seconds! I was under the impression that such UNIX OS actions were<br>
guaranteed to occur reliably in sequence!<br>
<br>
Note, the fs I'm using is local and normal harddisk-based. It is not on<br>
NFS or SMB, which of course could show such results.<br>
<br>
Comments? Ideas?<br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca" target="_blank">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</blockquote></div>
</blockquote></div>