Reputation: 1279
C02TPARXG8WN:fal$ python
Python 3.6.9 (default, Nov 10 2019, 01:00:31)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import signal
>>> signal.SIGHUP
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'signal' has no attribute 'SIGHUP'
>>>
testing signal on macos. unable to figure out why keep gettting signal error
C02TPARXG8WN:~ fc$ trap -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE 9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGURG 17) SIGSTOP 18) SIGTSTP 19) SIGCONT 20) SIGCHLD 21) SIGTTIN 22) SIGTTOU 23) SIGIO 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGINFO 30) SIGUSR1 31) SIGUSR2
from my system, "trap -l" shows a selection of signal
Upvotes: 4
Views: 11840
Reputation: 110
I used this code before the SIGHUP
usage to make it work on Windows, probably works on OS X too but I don't have a way to test it:
import platform
if platform.system() != 'Linux':
signal.SIGHUP = 1
After that, comes the SIGHUP usage and since 1
is the initial value on Linux, it'll work just like it was supposed to.
Since Python 3.7 signal.SIGHUP only works on Unix systems, so that doesn't include Windows...
I used platform.system() != 'Linux
since my script is only run on Windows and Linux, but you can accommodate it to your needs.
Platform docs: https://docs.python.org/3/library/platform.html#platform.system
Signal docs: enter link description here
signal.SIGHUP value on Linux
>>> import signal
>>> signal.SIGHUP
1
Upvotes: 3
Reputation: 7886
Base on the documentation, I would guess that either your device does not define SIGHUP
inside signal.h
, or that your python interpreter has been built on a device that is not completely equal to yours. If you are sure that SIGHUP
is defined, you best guess is reinstalling or even compiling python yourself.
Upvotes: 1