Results 1 to 4 of 4

Thread: How does one send a 'payload' with a signal?

  1. #1
    Join Date
    Jul 2007
    Location
    Toronto, Ontario, Canada
    Beans
    265

    How does one send a 'payload' with a signal?

    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?

  2. #2
    Join Date
    May 2008
    Location
    UK
    Beans
    1,450
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How does one send a 'payload' with a signal?

    You could use a shared memory map and use that to share information with your application - but a file might be easier.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

  3. #3
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,160
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: How does one send a 'payload' with a signal?

    Quote Originally Posted by ownaginatious View Post
    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?

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,160
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: How does one send a 'payload' with a signal?

    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)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •