Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '"""': 0.05; 'sys': 0.05; '__name__': 0.07; '**kwargs)': 0.09; '**kwargs):': 0.09; 'spawn': 0.09; 'subject:process': 0.09; 'def': 0.10; 'to:name:python-list': 0.15; "'__main__':": 0.16; 'reproduce': 0.16; 'simplified': 0.16; 'subject:changing': 0.16; 'true:': 0.16; 'fix': 0.17; 'appears': 0.18; 'trying': 0.21; 'import': 0.21; 'runs': 0.22; 'skip:_ 20': 0.22; 'machine': 0.24; 'pass': 0.25; 'skip:[ 10': 0.26; 'separate': 0.27; 'skip:@ 10': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'this?': 0.28; 'far,': 0.29; 'skip:_ 10': 0.29; "i'm": 0.29; 'becomes': 0.30; 'received:209.85.210.174': 0.30; 'function': 0.30; '(and': 0.32; 'running': 0.32; 'dies': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'version': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'process,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'child': 0.36; 'communicate': 0.37; 'received:209': 0.37; 'skip:o 20': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'real': 0.61; 'back': 0.62; 'do:': 0.91; 'processes,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Tm4pfwKc7TPHmsK0UE+hfMfCV3cNr0PpPB2XAkl2J78=; b=dAB9ukIa3T/ZefPka+gW5zymnCk34cPrv7uOIVEI9qriHAvhYxA3Xf32X/ByqJ9Psp kK6trhIifOBlZigMZMD81MWM1KOpqcPHbFu8Im2FDgKGIo46ebb8um/ZOv9ZWATjQOKa 9e0RypDtZf3VlVcBO0kbmZb7EexVp0jPXaEfOzkvOthwp7H/tfCAYg+oy2nabet78HtI kVVy4ABf7nJ/T7cOK1NwXR21jBAFz4VK2BwhZiV2HaGEq02qCYuAJ0mkqQA7OSezSo84 Npplc+NM4a0aH6Hohpu5/rC+ex4eQEHKP+P0OpXit+1h5ye+hhjZHZC41oPix7or95wk 5jzw== MIME-Version: 1.0 Date: Mon, 19 Nov 2012 10:39:29 +0000 Subject: changing process name From: andrea crotti To: python-list Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353321572 news.xs4all.nl 6907 [2001:888:2000:d::a6]:50256 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33536 I have very long processes to spawn which I want to lauch as separate processes (and communicate with ZeroMQ), but now the problem is that the forked process appears in "ps" with the same name as the launcher process. This is a simplified version of what I'm trying to do: import sys from os import fork, _exit def on_forked_process(func): """Decorator that forks the process, runs the function and gives back control to the main process """ def _on_forked_process(*args, **kwargs): pid = fork() if pid == 0: func(*args, **kwargs) _exit(0) else: return pid return _on_forked_process @on_forked_process def start_long_proc(): sys.argv[:] = [sys.argv[0]] + ['daemon', 'arguments'] from daemon import long_sleep long_sleep() if __name__ == '__main__': start_long_proc() # if the main process is still running but it's not told the child # when it dies then it becomes a zombie?? no apparently it doesn't while True: pass Where daemon.py: import sys import time def long_sleep(): sys.argv[:] = [sys.argv[0]] + ['daemon', 'arguments'] time.sleep(20) so both the sys.argv reassignment don't work so far, any other way to fix this? On the real machine I also get zombie processes, but on my machine I can't reproduce this, and would also be nice to fix that.. Thanks