By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,484 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,484 IT Pros & Developers. It's quick & easy.

sending signals upstream

P: n/a
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...

Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <11**********************@g14g2000cwa.googlegroups .com>,
bill <bi**********@gmail.com> 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
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.