PDA

View Full Version : How does one send a 'payload' with a signal?



ownaginatious
August 25th, 2011, 08:40 PM
So I have a program written in C that I want to send some information to every time I do a SIGUSR1 to it which it will read.

Now what I could do (which I feel is kind of a dumb solution) is write what I need to send it into a file, and then have it read that file as soon as the SIGUSR1 is executed to the process.

Is this really the best way to do this, or is there another smarter way without having to write anything to my hard-drive?

Tony Flury
August 26th, 2011, 09:31 AM
You could use a shared memory map and use that to share information with your application - but a file might be easier.

ofnuts
August 26th, 2011, 12:12 PM
So I have a program written in C that I want to send some information to every time I do a SIGUSR1 to it which it will read.

Now what I could do (which I feel is kind of a dumb solution) is write what I need to send it into a file, and then have it read that file as soon as the SIGUSR1 is executed to the process.

Is this really the best way to do this, or is there another smarter way without having to write anything to my hard-drive?Use a Fifo?

ofnuts
August 26th, 2011, 01:02 PM
Afterthought: depending on what your program does you could avoid the SIGUSR by just using a select() or pselect() inside the program (one of the file descriptors being a fifo)