FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ipython/IPython/utils/daemonize.py at master · unutbu/ipython · GitHub
unutbu
ipython
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ipython
/
IPython
/
utils
/
daemonize.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (22 loc) · 833 Bytes
Breadcrumbs
ipython
/
IPython
/
utils
/
daemonize.py
Copy path
File metadata and controls
26 lines (22 loc) · 833 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""daemonize function from twisted.scripts._twistd_unix."""
#-----------------------------------------------------------------------------
# Copyright (c) Twisted Matrix Laboratories.
# See Twisted's LICENSE for details.
# http://twistedmatrix.com/
#-----------------------------------------------------------------------------
import
os
,
errno
def
daemonize
():
# See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
if
os
.
fork
():
# launch child and...
os
.
_exit
(
0
)
# kill off parent
os
.
setsid
()
if
os
.
fork
():
# launch child and...
os
.
_exit
(
0
)
# kill off parent again.
null
=
os
.
open
(
'/dev/null'
,
os
.
O_RDWR
)
for
i
in
range
(
3
):
try
:
os
.
dup2
(
null
,
i
)
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EBADF
:
raise
os
.
close
(
null
)
Back
|
FazBrowse Home
|
New Git URL