[Tutor] pass argument into running program *outside* of program

Emile van Sebille emile at fenx.com
Tue Aug 26 01:58:40 CEST 2008


Ricardo Aráoz wrote:
> Emile van Sebille wrote:
>> I've done this and it works well... one thing to watch out for though 
>> is snagging a file before it's completely written.  Setting up a 
>> semaphore or pausing to allow the file write to complete once seeing 
>> the file fixes it adequately.
>>
> 
> If instead of an input/output file you use a directory this is easily 
> solved. You write your request to a uniquely named file (with .in 
> extension) 

But that doesn't solve the problem.  If you have a lot of data to be 
written to the '.in' file you need to wait for the file writes to 
complete before reading the contents on the 'other' side.  File 
existence isn't sufficient.  Perhaps writing to a '.tmp' and renaming it 
to '.in' after completely written might do it without the possibility of 
consuming the partial file before it's ready.


Emile



More information about the Tutor mailing list