Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: redirecting stdout and stderr to /dev/null Date: Sun, 08 May 2016 11:38:33 +1000 Lines: 32 Message-ID: References: <85inypfhwm.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de qldgRKnEI0dKWahJA+Im/g0bwHMcJRb6qHd8D12sWEjA== Cancel-Lock: sha1:/Dr8vpjBWo/+9PbCPw2NbqLhTN8= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'programs.': 0.11; '2016': 0.16; '8bit%:32': 0.16; 'hard-code': 0.16; 'invokes': 0.16; 'invoking': 0.16; 'learns': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:dev': 0.16; 'subprocess': 0.16; 'useless.': 0.16; 'wrote:': 0.16; 'programmer': 0.18; 'library': 0.20; 'explicit': 0.22; 'name;': 0.22; 'am,': 0.23; 'unix': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'command': 0.26; 'installed': 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'jim': 0.27; 'equivalent.': 0.29; 'subject:/': 0.30; 'that.': 0.30; 'code': 0.30; 'certainly': 0.30; 'strongly': 0.30; 'run': 0.33; 'url:python': 0.33; 'common': 0.33; 'particular,': 0.33; 'file': 0.34; 'platforms,': 0.35; 'but': 0.36; 'needed': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'names': 0.38; 'several': 0.38; 'system.': 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'care': 0.60; 'provide': 0.61; 'details': 0.62; 'different': 0.63; 'information': 0.63; 'food': 0.64; 'fact,': 0.67; 'repeat': 0.67; 'skip:\xe2 10': 0.70; 'certified': 0.83; '_o__)': 0.84; 'culinary': 0.84; 'received:125': 0.84; '8bit%:33': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <85inypfhwm.fsf@benfinney.id.au> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:108314 Chris Angelico writes: > On Sun, May 8, 2016 at 9:54 AM, Jim Dodgen wrote: > > The empty token is needed but useless, it is arg[0] most people just > > repeat the program name > > Far from useless. It's how a process learns its own name, and yes, > repeating the image name is the most common way to provide that. In particular, a program's name may not be its file name; it can be called by one of several different names dependeing on how it is installed on the system. Certainly the programmer writing the code cannot hard-code what the command name will be that invokes the program. Only ‘sys.argv[0]’, read at run time, can tell. > Indeed. In fact, I would strongly recommend never using an explicit > fork/exec from Python - always use subprocess or equivalent. On > non-Unix platforms, fork/exec may not be available, but subprocess can > use other methods of invoking programs. I've already mentioned earlier, but to be sure: the ‘python-daemon’ library takes care of the details of becoming a Unix daemon process. -- \ “… a Microsoft Certified System Engineer is to information | `\ technology as a McDonalds Certified Food Specialist is to the | _o__) culinary arts.” —Michael Bacarella | Ben Finney