Thread: How to Use POSIX for IPC Message To Another Process?

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    dedham, MA
    Posts
    10

    How to Use POSIX for IPC Message To Another Process?

    Hello,

    Does anyone know how to use standard POSIX libraries to make a call to some function that's part of a running daemon (background process).

    For example, suppose that some code within process1 wants to make a call to a routine called "do_trap()" in another Daemon. How does one do this using the standard POSIX libraries, does anyone know?

    Would I use signal.h functionality to accomplish this perhaps. If so, how? I've never done this before (in C).

    Thank you kindly,
    dedham_ma_man

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Generally, daemons have two types of interfaces:
    - Signals
    - Pipes/Sockets

    But you can also use named semaphores or other "global IPC" methods.

    "do_trap()" sounds like a case for a signal, which on the user-side would look like this:
    Code:
    ...
       kill(pid, signo);
    ...
    See for example:
    http://www.hmug.org/man/2/kill.php

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    .
    Join Date
    Nov 2003
    Posts
    307
    POSIX also supports message queues. They would probably not work as well for your app as some other IPC method, like named pipes or a socket, for example. Sockets are very commonly used by daemons that listen for requests and independently process them.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Location
    dedham, MA
    Posts
    10
    Thank you all for the great responses - I learned a great deal from them.

    I just found a good webpage that describes the basics of signaling, which is good for beginners to signaling like myself - http://www.cs.cf.ac.uk/Dave/C/node24...00000000000000

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in message handling VC++
    By 02mca31 in forum Windows Programming
    Replies: 5
    Last Post: 01-16-2009, 09:22 PM
  2. Desperate Over Ecs!
    By cookie in forum C Programming
    Replies: 17
    Last Post: 07-16-2008, 01:25 PM
  3. Process manipulation questions
    By Sfel in forum Windows Programming
    Replies: 7
    Last Post: 05-17-2008, 12:39 PM
  4. Character arrays in a Structure
    By vsriharsha in forum C Programming
    Replies: 7
    Last Post: 07-11-2004, 05:36 PM
  5. Message printing problem
    By robert_sun in forum C Programming
    Replies: 1
    Last Post: 05-18-2004, 05:05 AM