Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > sending signals upstream

Reply
Thread Tools

sending signals upstream

 
 
bill
Guest
Posts: n/a
 
      11-08-2005
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...

 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      11-08-2005
In article <(E-Mail Removed) .com>,
bill <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
T1 line bandwidth qustion Upstream downstream mdargin@msn.com Cisco 1 04-07-2006 12:03 AM
upstream proxy with Pix E. Helm Cisco 0 07-21-2003 01:07 AM
Re: How to be an upstream developer? Kline Sphere MCSD 1 07-03-2003 08:38 PM
Re: How to be an upstream developer? PJ Lee MCSD 1 07-02-2003 04:09 AM
How to be an upstream developer? Ken MCSD 0 06-30-2003 08:14 AM



Advertisments