Python without a tty
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Sep 29 06:52:22 EDT 2011
More information about the Python-list mailing list
Thu Sep 29 06:52:22 EDT 2011
- Previous message (by thread): Python without a tty
- Next message (by thread): Python without a tty
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alain Ketterlin wrote: > Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes: > >> I have a Python script which I would like to test without a tty attached >> to the process. I could run it as a cron job, but is there an easier way? >> >> I am running Linux. > > Isn't os.setsid() what you're looking for? It makes the calling process > have no controlling terminal. There's also a user command called setsid > that should have the same effect. It doesn't appear so to me. [steve at sylar ~]$ tty /dev/pts/16 [steve at sylar ~]$ setsid tty /dev/pts/16 [steve at sylar ~]$ python -c "import sys,os; print os.isatty(sys.stdout.fileno())" True [steve at sylar ~]$ setsid python -c "import sys,os; print os.isatty(sys.stdout.fileno())" True If I run the same Python command (without the setsid) as a cron job, I get False emailed to me. That's the effect I'm looking for. -- Steven
- Previous message (by thread): Python without a tty
- Next message (by thread): Python without a tty
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list