Differences between revisions 1 and 2
Revision 1 as of 2008-02-29 03:47:07
Size: 963
Editor: ZoomQuiet
Comment:
Revision 2 as of 2008-04-09 06:16:38
Size: 1010
Editor: ZoomQuiet
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from MicroProj/2008-02-29

::-- ZoomQuiet [DateTime(2008-02-29T03:47:07Z)] TableOfContents

Include(CPUGnav)

1. 自定Py脚本运行进程名

{{{沈崴 <[email protected]> reply-to [email protected], to "python-cn:CPyUG" <[email protected]>, date Fri, Feb 29, 2008 at 9:27 AM }}} subject [CPyUG:41663] Re: [http://groups.google.com/group/python-cn/browse_thread/thread/74e232c3d5dc7d78/353464f2731c5ddd 如何改变python脚本的进程名?]

   1 #!/usr/bin/env python
   2 procname = 'Hello'
   3 
   4 import os, sys
   5 if not os.environ.has_key('NEWPROCNAME'):
   6        os.execlpe(sys.executable, procname, __file__, {'NEWPROCNAME':
   7 procname})
   8 
   9 import dl
  10 libc = dl.open('/lib/libc.so.6')
  11 libc.call('prctl', 15, '%s\0' %procname, 0, 0, 0)
  12 # BSD
  13 # libc.call('setproctitle', '%s\0' %procname)

PageComment2 [:/PageCommentData:PageCommentData]

MiscItems/2008-02-29 (last edited 2009-12-25 07:17:59 by localhost)