Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108314 > unrolled thread

Re: redirecting stdout and stderr to /dev/null

Started byBen Finney <ben+python@benfinney.id.au>
First post2016-05-08 11:38 +1000
Last post2016-05-08 11:38 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: redirecting stdout and stderr to /dev/null Ben Finney <ben+python@benfinney.id.au> - 2016-05-08 11:38 +1000

#108314 — Re: redirecting stdout and stderr to /dev/null

FromBen Finney <ben+python@benfinney.id.au>
Date2016-05-08 11:38 +1000
SubjectRe: redirecting stdout and stderr to /dev/null
Message-ID<mailman.488.1462671525.32212.python-list@python.org>
Chris Angelico <rosuav@gmail.com> writes:

> On Sun, May 8, 2016 at 9:54 AM, Jim Dodgen <jim@dodgen.us> 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 <URL:https://pypi.python.org/pypi/python-daemon/> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web