sigqueue

How do I receive a signal sent with sigqueue in a c program (on linux)?

百般思念 提交于 2019-12-10 12:53:32
问题 How do I receive receive a signal sent with sigqueue in a c program (on linux)? If just use kill to send a signal I just add a receiver with something like this signal(SIGUSR1, sigusr1); that point to a simple function like this: void sigusr1() { signal(SIGUSR1,sigusr1); printf("SIGUSR1 ....\n"); } But if I send a signal with sigqueue, how would I do then? Thanks Johan Add a sigaction: struct sigaction action; action.sa_flags = SA_SIGINFO; action.sa_sigaction = &sigusr2; if (sigaction(SIGUSR2

How do I send and receive real-time signals `sigqueue()` in Python?

那年仲夏 提交于 2019-12-07 21:52:43
问题 Python provides a signals module and os.kill ; does it have a facility for sigqueue() (real-time signals with attached data)? What are the alternatives? 回答1: You could do it with ctypes >>> from ctypes import * >>> c = cdll.LoadLibrary("libc.so.6") >>> c.sigqueue <_FuncPtr object at 0xb7dbd77c> >>> c.sigqueue(100, 10, 0) -1 >>> You'll have to look up how to make a union in ctypes which I've never done before but I think is possible. 回答2: One alternative, if no one has done it yet, would be to

How do I send and receive real-time signals `sigqueue()` in Python?

人盡茶涼 提交于 2019-12-06 07:44:27
Python provides a signals module and os.kill ; does it have a facility for sigqueue() (real-time signals with attached data)? What are the alternatives? You could do it with ctypes >>> from ctypes import * >>> c = cdll.LoadLibrary("libc.so.6") >>> c.sigqueue <_FuncPtr object at 0xb7dbd77c> >>> c.sigqueue(100, 10, 0) -1 >>> You'll have to look up how to make a union in ctypes which I've never done before but I think is possible. One alternative, if no one has done it yet, would be to wrap the C library yourself - should be pretty quick and painless. Look here for more details. 来源: https:/

Is the data in siginfo trustworthy?

梦想的初衷 提交于 2019-12-04 19:28:23
问题 I've found that on Linux, by making my own call to the rt_sigqueue syscall, I can put whatever I like in the si_uid and si_pid fields and the call succeeds and happily delivers the incorrect values. Naturally the uid restrictions on sending signals provide some protection against this kind of spoofing, but I'm worried it may be dangerous to rely on this information. Is there any good documentation on the topic I could read? Why does Linux allow the obviously-incorrect behavior of letting the