/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
internet
/
/usr/lib/python3/dist-packages/twisted/internet
mkdir
upload
Name
Size
Mode
Actions
iocpreactor/
-
0755
rm
test/
-
0755
rm
__pycache__/
-
0755
rm
abstract.py
19274
0644
edit
dl
rm
address.py
5246
0644
edit
dl
rm
asyncioreactor.py
10553
0644
edit
dl
rm
base.py
44260
0644
edit
dl
rm
cfreactor.py
17501
0644
edit
dl
rm
default.py
1942
0644
edit
dl
rm
defer.py
71193
0644
edit
dl
rm
endpoints.py
77207
0644
edit
dl
rm
epollreactor.py
8493
0644
edit
dl
rm
error.py
12645
0644
edit
dl
rm
fdesc.py
3223
0644
edit
dl
rm
gireactor.py
6123
0644
edit
dl
rm
glib2reactor.py
1115
0644
edit
dl
rm
gtk2reactor.py
3614
0644
edit
dl
rm
gtk3reactor.py
2252
0644
edit
dl
rm
inotify.py
14691
0644
edit
dl
rm
interfaces.py
96515
0644
edit
dl
rm
kqreactor.py
10292
0644
edit
dl
rm
main.py
1054
0644
edit
dl
rm
pollreactor.py
6026
0644
edit
dl
rm
posixbase.py
26357
0644
edit
dl
rm
process.py
38896
0644
edit
dl
rm
protocol.py
27134
0644
edit
dl
rm
pyuisupport.py
817
0644
edit
dl
rm
reactor.py
1863
0644
edit
dl
rm
selectreactor.py
6215
0644
edit
dl
rm
serialport.py
2317
0644
edit
dl
rm
ssl.py
8444
0644
edit
dl
rm
stdio.py
1045
0644
edit
dl
rm
task.py
31119
0644
edit
dl
rm
tcp.py
54908
0644
edit
dl
rm
threads.py
3953
0644
edit
dl
rm
tksupport.py
2045
0644
edit
dl
rm
udp.py
18569
0644
edit
dl
rm
unix.py
21965
0644
edit
dl
rm
utils.py
7876
0644
edit
dl
rm
win32eventreactor.py
15193
0644
edit
dl
rm
wxreactor.py
5263
0644
edit
dl
rm
wxsupport.py
1363
0644
edit
dl
rm
_baseprocess.py
1913
0644
edit
dl
rm
_dumbwin32proc.py
13107
0644
edit
dl
rm
_glibbase.py
12813
0644
edit
dl
rm
_idna.py
1397
0644
edit
dl
rm
_newtls.py
9332
0644
edit
dl
rm
_pollingfile.py
8982
0644
edit
dl
rm
_posixserialport.py
1995
0644
edit
dl
rm
_posixstdio.py
4687
0644
edit
dl
rm
_producer_helpers.py
3788
0644
edit
dl
rm
_resolver.py
8530
0644
edit
dl
rm
_signals.py
2718
0644
edit
dl
rm
_sslverify.py
71770
0644
edit
dl
rm
_threadedselect.py
11764
0644
edit
dl
rm
_win32serialport.py
4744
0644
edit
dl
rm
_win32stdio.py
3204
0644
edit
dl
rm
__init__.py
521
0644
edit
dl
rm
Edit:
/usr/lib/python3/dist-packages/twisted/internet/_signals.py
(2718B)
# -*- test-case-name: twisted.internet.test.test_sigchld -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ This module is used to integrate child process termination into a reactor event loop. This is a challenging feature to provide because most platforms indicate process termination via SIGCHLD and do not provide a way to wait for that signal and arbitrary I/O events at the same time. The naive implementation involves installing a Python SIGCHLD handler; unfortunately this leads to other syscalls being interrupted (whenever SIGCHLD is received) and failing with EINTR (which almost no one is prepared to handle). This interruption can be disabled via siginterrupt(2) (or one of the equivalent mechanisms); however, if the SIGCHLD is delivered by the platform to a non-main thread (not a common occurrence, but difficult to prove impossible), the main thread (waiting on select() or another event notification API) may not wake up leading to an arbitrary delay before the child termination is noticed. The basic solution to all these issues involves enabling SA_RESTART (ie, disabling system call interruption) and registering a C signal handler which writes a byte to a pipe. The other end of the pipe is registered with the event loop, allowing it to wake up shortly after SIGCHLD is received. See L{twisted.internet.posixbase._SIGCHLDWaker} for the implementation of the event loop side of this solution. The use of a pipe this way is known as the U{self-pipe trick<http://cr.yp.to/docs/selfpipe.html>}. From Python version 2.6, C{signal.siginterrupt} and C{signal.set_wakeup_fd} provide the necessary C signal handler which writes to the pipe to be registered with C{SA_RESTART}. """ from __future__ import division, absolute_import import signal def installHandler(fd): """ Install a signal handler which will write a byte to C{fd} when I{SIGCHLD} is received. This is implemented by installing a SIGCHLD handler that does nothing, setting the I{SIGCHLD} handler as not allowed to interrupt system calls, and using L{signal.set_wakeup_fd} to do the actual writing. @param fd: The file descriptor to which to write when I{SIGCHLD} is received. @type fd: C{int} """ if fd == -1: signal.signal(signal.SIGCHLD, signal.SIG_DFL) else: def noopSignalHandler(*args): pass signal.signal(signal.SIGCHLD, noopSignalHandler) signal.siginterrupt(signal.SIGCHLD, False) return signal.set_wakeup_fd(fd) def isDefaultHandler(): """ Determine whether the I{SIGCHLD} handler is the default or not. """ return signal.getsignal(signal.SIGCHLD) == signal.SIG_DFL
Save
cmd:
run