Prev: exec - problem with stderr
Next: Is there a reason that ActiveTcl does not have an 64bit distribution?
From: Neil on 16 Jul 2010 19:46 >> But this raises to another question : is it possible to check whether >> a file is still opened by another program ? Which raises another question: does the program keep the file open? If it just pipes text into it, or opens and closes it for every write, it may close it and expect to be able to open it again (eg, createfile with dwCreationDisposition of OPEN_EXISTING; which would cause issues like you describe.) http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx Essentially, you check file handles to see if a file is open; but you'd need to test it to see if it still breaks. Assuming it uses a handle...which isn't guaranteed. > I don't think Windows has any qualms > about multiple programs accessing a file simultaneously for reading, It depends on how a file is opened. If you call CreateFile internally, you have lots of locking options: http://msdn.microsoft.com/en-us/library/aa363874%28v=VS.85%29.aspx Here's a snippet that might do what you want: regedt32 in XP merely launches regedit and returns. This snippet launches regedt32, then waits for regedit to terminate before it continues. I ran it, it works. It's very simple. package require twapi exec regedt32.exe while {[string length [::twapi::get_process_ids -name regedit.exe]]} {;} puts "Grandchild has exited" You're guaranteed that by the time process child returns, process grandchild will already be running, and that when process grandchild terminates, your text file is moot. You could do it without twapi, if you needed. (eg: tasklist | find "regedit") HTH
From: Alexandre Ferrieux on 17 Jul 2010 05:56 On Jul 16, 5:07 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > PS: if you really can't do otherwise, try adding to the end of your > > matlab script (before exit) something that creates yet another > > signalling file, after closing the result file. This way, by > > monitoring the second one you're sure that the first is closed. > > I have been thinking about creating another dummy file in the end of > matlab too. But, just in case, if the loop come back faster then the > file being closed by matlab, it will cause problem again. > Any hint ? Read again my suggestion: it is about creating the signalling file with an instruction inside the matlab script. So the "loop coming back" (more precisely, the matlab script returning) implies this instruction has been executed. No race here. -Alex
First
|
Prev
|
Pages: 1 2 Prev: exec - problem with stderr Next: Is there a reason that ActiveTcl does not have an 64bit distribution? |