Killing A Process By PID

Michael Bentley michael at jedimindworks.com
Sat Sep 22 00:42:14 EDT 2007


On Sep 20, 2007, at 7:46 PM, Arvind Singh wrote:
> file('/var/lock/Application.lock', 'w').write(str(os.getpid()))
>
>  Which to be honest appears to run just fine, when I look in that  
> file it always contains the correct process ID, for instance, 3419  
> or something like that.
>
> I honestly doubt that. The I/O is buffered and you need to flush()/ 
> close() the file. Otherwise data may not get written until python  
> interpreter exits.

Isn't the file closed after the file().write()?  Seems to me that the  
great garbage collector in the sky will happily flush(), close() and  
forget it ever happened...

-Michael

---
"Those who don't understand UNIX are condemned to reinvent it,  
poorly."  --Henry Spencer



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070921/7234304c/attachment.html>


More information about the Python-list mailing list