sending signals upstream

Discussion in 'C Programming' started by bill, Nov 8, 2005.

  1. bill

    bill Guest

    This is not strictly a C question, but groups such as comp.unix.wizards
    seem to have died. Does anyone know the appropriate group for this
    question?

    I want to signal an upstream process. eg:
    % a | b | c | d
    and d wants to send a signal to a.
    The problem is: how does d get a's pid. I see 4 solutions:


    1) a writes its pid information into the pipe.
    drawback) intermediate processes need to deal with it. This
    makes it difficult to use them arbitrarily as the start of the pipe
    as now:
    % cat foo | b | c
    is problematic. A simple solution for this
    is to take a command line arg to indicate start of pipe: eg
    % cat foo | b -s | c...

    2) a writes its pid on stderr and I do something ugly like:
    % ( a | b | c ) 2>&1 | d
    drawback) ugly as sin, difficult to handle multiple upstream
    data paths, and I lose stderr. (I could use fd 3 instead, eg "3>&1",
    but this is going to get real ugly, real fast.)

    3) a registers its pid in a pid file. eg /var/run/a.xxx where
    xxx is the gid. This is pretty decent, but there are some
    naming conflicts in a pipe that looks like
    % a | b | c| d | a | b | c | d
    as both instances of a have the same gid.
    In all the instances I can think of at the moment, d will want
    to signal the process that is closest to it in the pipe, so it
    can parse the pid file and pick the one with the pid closest
    to its own, but this is inherently inflexible. It also relies on the
    pids being assigned montonically
    (ie d > c > b > a), and I'm not sure that's reliable.

    4) Write a controlling process that catches the signals and
    farms them out appropriately. Unfortunately, I think that this
    and solution 1 are the only things that will really work. But
    writing the parent means I completely lose the ability to
    simply enter commands at the shell prompt, and I really
    want that. I can't see a good way to write it as a
    shell script, as if we include the line:
    a | b | c | d &
    in the script, I don't know how to get a's pid.

    I'm hoping someone can give me solution number 5...
     
    bill, Nov 8, 2005
    #1
    1. Advertising

  2. In article <>,
    bill <> wrote:
    >This is not strictly a C question, but groups such as comp.unix.wizards
    >seem to have died. Does anyone know the appropriate group for this
    >question?


    comp.unix.programming


    >I want to signal an upstream process. eg:
    >% a | b | c | d
    >and d wants to send a signal to a.
    >The problem is: how does d get a's pid. I see 4 solutions:


    [OT]

    process groups
    --
    All is vanity. -- Ecclesiastes
     
    Walter Roberson, Nov 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Haim Ashkenazi

    sending signals to the calling function

    Haim Ashkenazi, Jun 28, 2004, in forum: Python
    Replies:
    1
    Views:
    430
    Mathias Waack
    Jun 29, 2004
  2. Jaco Smuts
    Replies:
    0
    Views:
    404
    Jaco Smuts
    Jun 28, 2004
  3. Sarir Khamsi

    sending signals to child process

    Sarir Khamsi, Apr 8, 2005, in forum: Python
    Replies:
    2
    Views:
    360
    Sarir Khamsi
    Apr 9, 2005
  4. Moe Sisko

    upstream compression ?

    Moe Sisko, Apr 8, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    375
    George Ter-Saakov
    Apr 8, 2008
  5. Carl Banks
    Replies:
    2
    Views:
    307
    Carl Banks
    Mar 11, 2009
Loading...

Share This Page