It is currently Tue, 30 Nov 2021 17:43:41 GMT



 
Author Message
 child process' killer's pid
This is the scenario:
   ~ process X forks child process Y
   ~ process Z sends process Y a SIGKILL
   ~ process Z exits

At this point would process X have access to process Z's pid (before
it exited)?

I know how to determine the signal that caused the death of process Y
but cannot find any info about how to get Z's pid.

/*
 * I am running on an HP-UX 11.00 platform.
 */

Thanks,
Marcus



 Sun, 10 Apr 2005 18:48:23 GMT   
 child process' killer's pid
In article <109a8eb.0210230248.4a68a...@posting.google.com>,
        Marcus_Bo...@raytheon.com (mbmb) writes:

Don't you think this is rather more a Unix question [because Unix has
processes and forks ands knives to KILL things with] than a C question
[because C has no processes and no forks], and so would be better asked
in, say, comp.unix.programm[er|ing]?

Perhaps you cannot. Perhaps Z is an alias for Vlad Taltos or Mario Greymist,
and you will not be able to trace his identity.

Or perhaps in an hp-specific newsgroup, if there are any public ones,
but alas! I know not if there are.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html



 Sun, 10 Apr 2005 18:58:29 GMT   
 child process' killer's pid
On 23 Oct 2002 03:48:23 -0700, Marcus_Bo...@raytheon.com (mbmb) wrote:

Your scenario doesn't seem complete.   You didn't specify what the
(X,Z) and (Y,Z) relationships are.

As I recall, in order for Z to send Y a SIGKILL, Z must know Y's PID.
This means there's some communication  either Y to Z or  X to Z.   I
reason this because other than the OS, the only processes I can assume
know Y's PID are X (Y's parent) and Y (itself).    I don't know how to
get the correct PID from the OS.

As far as I know, there's no fundamental reason why X would have
access to Z's PID just because it could SIGKILL one of X's children.

If Z was another child process of X, then X would have the PID of both
Y and Z.

If Z shares a shared memory space with X then Z could pass a message
containing Z's PID this way to X.

If Z and X are connected via some form of pipes, then Z could pass a
message containing  Z's PID this way to X.

-----------
Thanks

MCheu



 Sun, 10 Apr 2005 20:15:42 GMT   
 child process' killer's pid

a program that receives a signal does not receive any pid, if you mean that



 Sun, 10 Apr 2005 20:28:52 GMT   
 child process' killer's pid
In article <ap5vcl$ll...@murdoch.hpl.hp.com>,

No.  There is no way of knowing where the signal came from.  A signal
doesn't have to be generated by a process.

Which it was cross-posted to.  Shouldn't you zealots in CLC restrict
your flames for inappropriately posting to CLC to CLC,  instead
of cross-posting them back?

comp.sys.hp.hpux

--
Dan Mercer
damer...@mmm.com

If responding by email, include the phrase 'from usenet'
in the subject line to avoid spam filtering.

Opinions expressed herein are my own and may not represent those of my employer.



 Sun, 10 Apr 2005 20:49:52 GMT   
 child process' killer's pid
In <ap5vcl$ll...@murdoch.hpl.hp.com> k...@hplb.hpl.hp.com () writes:

Apparently, he does, because the first newsgroup in the Newsgroups
header line is comp.unix.programmer.

Since the thread is already crossposted there, I fail to see the point
of your advice.

If you want to complain about the inclusion of comp.lang.c in the
Newsgroups line, then just do it.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan....@ifh.de



 Sun, 10 Apr 2005 20:03:21 GMT   
 child process' killer's pid

No, because it is the responsibility of the OP to post on relevant
newsgroups, rather than blatently spreading OT queries over the
face of USENET.

--
Chuck F (cbfalco...@yahoo.com) (cbfalco...@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!



 Sun, 10 Apr 2005 22:54:46 GMT   
 child process' killer's pid
In article <ap6369$6k...@sunnews.cern.ch>,
        Dan....@ifh.de (Dan Pop) writes:

A fact which I spotted just after I pressed the send button. Oops.

Surely, Dan, you don't expect perfection of me. I missed the cross-post;
it happens.

I'm really cross that the OP included comp.lang.c in the Newsgroups
line.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html



 Sun, 10 Apr 2005 23:00:44 GMT   
 child process' killer's pid
In article <ap65tg$9j...@magnum.mmm.com>,
        damer...@mmm.com (Dan Mercer) writes:

Sorry. Missed the cross-posting ikky thingy.

Er ... `flame`? I wrote a flame? I don't think so. Eggworthy, perhaps,
but *flame*?

You are Ford Prefect and I claim my five pounds.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html



 Sun, 10 Apr 2005 23:03:54 GMT   
 child process' killer's pid

Maybe you should killfile anything with "comp.unix" in Newsgroups.  Then
you won't be bothered by the OT posts in the first place.

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Sun, 10 Apr 2005 23:26:16 GMT   
 child process' killer's pid
In article <sczt9.8$9F6.1...@paloalto-snr1.gtei.net>,
        Barry Margolin <bar...@genuity.net> writes:

(a) I should be so lucky.
(b) that's gratuitously excessive.
(c) when I say "sorry", I mean it.

Point of clarification: the "ikky thingy" was the act of cross-pointing,
not comp.unix.*, in case anyone read it otherwise. Sorry for any
unintended ambiguity.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html



 Sun, 10 Apr 2005 23:38:11 GMT   
 child process' killer's pid
In article <mg3drugo7rhircr556au5236dnfdpac...@4ax.com>,

People often get it by grepping the output of "ps".  Also, Y could write
its PID to a file, which Z then reads (a number of daemons work this way).

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Sun, 10 Apr 2005 23:28:54 GMT   
 child process' killer's pid
In <sczt9.8$9F6.1...@paloalto-snr1.gtei.net> Barry Margolin <bar...@genuity.net> writes:

That would work in an ideal world.  In the real one, most of the Unix
specific stuff posted in c.l.c is not crossposted to c.u.p.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan....@ifh.de



 Mon, 11 Apr 2005 01:27:52 GMT   
 child process' killer's pid
In article <3DB6AE43.5A3E6...@yahoo.com>,

But isn't whether or not the relevancy of original post to CLC
only relevant to CLC,  in which case the flame is irrelevant to
CUP,  and the responder has committed the same faux pas as the OP.

--
Dan Mercer
damer...@mmm.com

If responding by email, include the phrase 'from usenet'
in the subject line to avoid spam filtering.

Opinions expressed herein are my own and may not represent those of my employer.



 Mon, 11 Apr 2005 02:56:23 GMT   
 child process' killer's pid

Determining process Z's pid and uid from process X in signal handler:

#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <signal.h>
#include <siginfo.h>

void sig_handler (int sig, siginfo_t * sinfo, void * v);

int main (void) {
  struct sigaction sa;
  sa.sa_sigaction = &sig_handler;
  sa.sa_flags = SA_SIGINFO;
  assert(sigaction(SIGTERM, &sa, NULL) != -1);
  printf("My pid is [%d]\n", (int) getpid());
  pause();
  return 0;

void sig_handler (int sig, siginfo_t * sinfo, void * v) {
  if (sinfo->si_code <= 0) { /* generated by user process */
    printf("Process [%d] killed me\n", (int)sinfo->si_pid);
    printf("And it was user [%d] who did it.\n", (int)sinfo->si_uid);
  }

See man pages on sigaction and siginfo.

[tested on]
$ uname -a
SunOS jabba 5.7 Generic_106541-22 sun4u sparc SUNW,Ultra-4



 Mon, 11 Apr 2005 08:31:51 GMT   
 
   [ 20 post ]  Go to page: [1] [2]

Similar Threads

1. Getting a child and child's child process-id

2. Getting a child and child's child process-id

3. pid 25's child link is bad

4. child's parent PID is 1 ???

5. Child's PID ??

6. finding parent pid of someelse's child

7. [TRIVIAL] don't let OOM killer kill same process repeatedly

8. Security: Process-Killer if machine get's out of memory

9. Child process PID


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software