* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
@ 2003-04-03 3:00 gavin bowlby
2003-04-03 3:05 ` gavin bowlby
2003-04-03 3:19 ` Christopher Faylor
0 siblings, 2 replies; 8+ messages in thread
From: gavin bowlby @ 2003-04-03 3:00 UTC (permalink / raw)
To: cygwin, cgf, corinna-cygwin
>Ok. In that event, please provide a simple test
case.
Christopher, Corinna:
Thanks for you help on this!
Here's a short program to recreate this problem:
("main.c")
=====================================================
int main(int argc, char *argv[]) {
int pid, sid, rc;
if ((pid = fork()) == 0) {
// child thread
pid = getppid();
while(1) {
rc = sleep(10);
printf("child is alive...\n");
if ((sid = getpgid(pid)) == -1) {
printf("exiting child process...rc=2\n");
exit(2);
}
}
}
else {
// parent thread
while(1) {
rc = sleep(10);
printf("parent is alive...\n");
// check if our child process has been killed
if ((sid = getpgid(pid)) == -1)
exit(3);
printf("getpgid of child pid:%d returned
pid:%d\n", pid, sid);
}
}
}
==========================================
and here are the steps I used to find the problem:
1) bring up Cygwin shell 1
2) gcc main.c <create executable>
3) a.exe <run executable>
4) let program run 10-15 seconds to see output from
parent and child
5) bring up Cygwin shell 2
6) ps <to see PIDs of parent and child>
7) kill -9 <child PID>
8) observe that parent continues to run, and sees
the parent's PID reported as the result of the
getpgid
BTW, the same problem occurs if the parent PID is
killed - the child continues to see that the parent
PID is alive.
The general problem I'm trying to solve here is:
Given a long-lived parent process and a long-lived
child process, I want the parent and child to be able
to detect if the child or parent has died, and if so,
exit.
Thanks again for your kind assistance.
Gavin Bowlby
<gavin_bowlby@yahoo.com>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
2003-04-03 3:00 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists gavin bowlby
@ 2003-04-03 3:05 ` gavin bowlby
2003-04-03 3:19 ` Christopher Faylor
1 sibling, 0 replies; 8+ messages in thread
From: gavin bowlby @ 2003-04-03 3:05 UTC (permalink / raw)
To: cygwin, cgf, corinna-cygwin
>Ok. In that event, please provide a simple test
case.
Christopher, Corinna:
Thanks for you help on this!
Here's a short program to recreate this problem:
("main.c")
=====================================================
int main(int argc, char *argv[]) {
int pid, sid, rc;
if ((pid = fork()) == 0) {
// child thread
pid = getppid();
while(1) {
rc = sleep(10);
printf("child is alive...\n");
if ((sid = getpgid(pid)) == -1) {
printf("exiting child process...rc=2\n");
exit(2);
}
}
}
else {
// parent thread
while(1) {
rc = sleep(10);
printf("parent is alive...\n");
// check if our child process has been killed
if ((sid = getpgid(pid)) == -1)
exit(3);
printf("getpgid of child pid:%d returned
pid:%d\n", pid, sid);
}
}
}
==========================================
and here are the steps I used to find the problem:
1) bring up Cygwin shell 1
2) gcc main.c <create executable>
3) a.exe <run executable>
4) let program run 10-15 seconds to see output from
parent and child
5) bring up Cygwin shell 2
6) ps <to see PIDs of parent and child>
7) kill -9 <child PID>
8) observe that parent continues to run, and sees
the parent's PID reported as the result of the
getpgid
BTW, the same problem occurs if the parent PID is
killed - the child continues to see that the parent
PID is alive.
The general problem I'm trying to solve here is:
Given a long-lived parent process and a long-lived
child process, I want the parent and child to be able
to detect if the child or parent has died, and if so,
exit.
Thanks again for your kind assistance.
Gavin Bowlby
<gavin_bowlby@yahoo.com>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
2003-04-03 3:00 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists gavin bowlby
2003-04-03 3:05 ` gavin bowlby
@ 2003-04-03 3:19 ` Christopher Faylor
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Faylor @ 2003-04-03 3:19 UTC (permalink / raw)
To: gavin bowlby; +Cc: cygwin
On Wed, Apr 02, 2003 at 06:43:16PM -0800, gavin bowlby wrote:
>>Ok. In that event, please provide a simple test case.
>
>Here's a short program to recreate this problem:
>
>("main.c")
>=====================================================
>int main(int argc, char *argv[]) {
>
> int pid, sid, rc;
>
> if ((pid = fork()) == 0) {
> // child thread
> pid = getppid();
> while(1) {
> rc = sleep(10);
> printf("child is alive...\n");
> if ((sid = getpgid(pid)) == -1) {
> printf("exiting child process...rc=2\n");
> exit(2);
> }
> }
> }
> else {
> // parent thread
> while(1) {
> rc = sleep(10);
> printf("parent is alive...\n");
> // check if our child process has been killed
> if ((sid = getpgid(pid)) == -1)
> exit(3);
>
> printf("getpgid of child pid:%d returned
>pid:%d\n", pid, sid);
> }
> }
>}
>==========================================
>and here are the steps I used to find the problem:
>
>1) bring up Cygwin shell 1
>2) gcc main.c <create executable>
>3) a.exe <run executable>
>4) let program run 10-15 seconds to see output from
> parent and child
>5) bring up Cygwin shell 2
>6) ps <to see PIDs of parent and child>
>7) kill -9 <child PID>
>8) observe that parent continues to run, and sees
> the parent's PID reported as the result of the
> getpgid
>
>BTW, the same problem occurs if the parent PID is killed - the child
>continues to see that the parent PID is alive.
Try it on UNIX/Linux. Same behavior. The pid exists until you wait()
for it. Add a 'waitpid (pid, &stat, WNOHANG);' before the parent's
getpgid and the loop will terminate on Cygwin or UNIX.
cgf
--
Please use the resources at cygwin.com rather than sending personal email.
Special for spam email harvesters: send email to aaaspam@sourceware.org
and be permanently blocked from mailing lists at sources.redhat.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
2003-04-02 20:20 gavin bowlby
2003-04-02 20:23 ` gavin bowlby
@ 2003-04-02 23:24 ` Christopher Faylor
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Faylor @ 2003-04-02 23:24 UTC (permalink / raw)
To: cygwin
On Wed, Apr 02, 2003 at 12:20:56PM -0800, gavin bowlby wrote:
>Thanks for your suggestion. Sorry I didn't upgrade before reporting
>this problem. I still see the same problem with 1.3.22.
Ok. In that event, please provide a simple test case.
cgf
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
2003-04-02 20:20 gavin bowlby
@ 2003-04-02 20:23 ` gavin bowlby
2003-04-02 23:24 ` Christopher Faylor
1 sibling, 0 replies; 8+ messages in thread
From: gavin bowlby @ 2003-04-02 20:23 UTC (permalink / raw)
To: cygwin, corinna-cygwin
Corinna:
Thanks for your suggestion. Sorry I didn't upgrade
before reporting this problem. I still see the same
problem with 1.3.22.
Here's a console log:
From the parent's perspective: (parent program name is
"pglm" parent's pid=1940, child's program name is
"pglm", child's pid=1624)
getpgid of child pid:1624 returned pid:1940
==============================================
A ps command from another Cygwin shell shows:
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ ps
PID PPID PGID WINPID TTY UID
STIME COMMAND
1232 1 1232 1232 con 1003
11:56:48 /usr/bin/bash
1964 1 1964 1964 con 1003
11:57:54 /usr/bin/bash
1940 1232 1940 948 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
1624 1940 1940 1624 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
1724 1964 1724 732 con 1003
12:03:52 /usr/bin/ps
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ kill -9 1624
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ ps
PID PPID PGID WINPID TTY UID
STIME COMMAND
1232 1 1232 1232 con 1003
11:56:48 /usr/bin/bash
1964 1 1964 1964 con 1003
11:57:54 /usr/bin/bash
1940 1232 1940 948 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
2092 1964 2092 1504 con 1003
12:04:32 /usr/bin/ps
===================================================
After the kill -9 1624 is issued, the running parent
process continues to output:
getpgid of child pid:1624 returned pid:1940
after calls to getpgid with a pid of 1624.
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ uname -a
CYGWIN_NT-5.0 reptilicus 1.3.22(0.78/3/2) 2003-03-18
09:20 i686 unknown unknown
Cygwin
Thanks again for your help,
Gavin Bowlby
(gavin_bowlby@yahoo.com)
======================================================
On Tue, Apr 01, 2003 at 07:06:45PM -0800, gavin bowlby
wrote:
> $ uname -a
> CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
> 12:10 i686 unknown unknown
> Cygwin
Could you test with 1.3.22 please?
Corinna
--
Corinna Vinschen Please, send mails
regarding Cygwin to
Cygwin Developer
mailto:cygwin at cygwin dot com
Red Hat, Inc.
--- gavin bowlby <gavin_bowlby@yahoo.com> wrote:
> $ uname -a
> CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
> 12:10 i686 unknown unknown
> Cygwin
>
> Windows 2K box.
>
> Process A creates Process B.
>
> I kill Process B with a "kill -9 <process B's pid>"
>
> Process A then does a:
>
> sid = getpgid(pid));
>
> pid is set to process B's pid
>
> sid is not returned as -1, even though process B no
> longer exists, as can be seen with a "ps" command.
> This occurs repeatedly.
>
> Is this correct behavior?
>
> Regards,
>
> Gavin Bowlby
>
> gavin_bowlby@yahoo.com
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms,
> and more
> http://tax.yahoo.com
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
@ 2003-04-02 20:20 gavin bowlby
2003-04-02 20:23 ` gavin bowlby
2003-04-02 23:24 ` Christopher Faylor
0 siblings, 2 replies; 8+ messages in thread
From: gavin bowlby @ 2003-04-02 20:20 UTC (permalink / raw)
To: cygwin, corinna-cygwin
Corinna:
Thanks for your suggestion. Sorry I didn't upgrade
before reporting this problem. I still see the same
problem with 1.3.22.
Here's a console log:
From the parent's perspective: (parent program name is
"pglm" parent's pid=1940, child's program name is
"pglm", child's pid=1624)
getpgid of child pid:1624 returned pid:1940
==============================================
A ps command from another Cygwin shell shows:
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ ps
PID PPID PGID WINPID TTY UID
STIME COMMAND
1232 1 1232 1232 con 1003
11:56:48 /usr/bin/bash
1964 1 1964 1964 con 1003
11:57:54 /usr/bin/bash
1940 1232 1940 948 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
1624 1940 1940 1624 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
1724 1964 1724 732 con 1003
12:03:52 /usr/bin/ps
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ kill -9 1624
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ ps
PID PPID PGID WINPID TTY UID
STIME COMMAND
1232 1 1232 1232 con 1003
11:56:48 /usr/bin/bash
1964 1 1964 1964 con 1003
11:57:54 /usr/bin/bash
1940 1232 1940 948 con 1003
12:03:35 /cygdrive/c/cadzilla/pgl
m/pglm
2092 1964 2092 1504 con 1003
12:04:32 /usr/bin/ps
===================================================
After the kill -9 1624 is issued, the running parent
process continues to output:
getpgid of child pid:1624 returned pid:1940
after calls to getpgid with a pid of 1624.
gavin@reptilicus /cygdrive/c/cadzilla/pglm
$ uname -a
CYGWIN_NT-5.0 reptilicus 1.3.22(0.78/3/2) 2003-03-18
09:20 i686 unknown unknown
Cygwin
Thanks again for your help,
Gavin Bowlby
(gavin_bowlby@yahoo.com)
======================================================
On Tue, Apr 01, 2003 at 07:06:45PM -0800, gavin bowlby
wrote:
> $ uname -a
> CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
> 12:10 i686 unknown unknown
> Cygwin
Could you test with 1.3.22 please?
Corinna
--
Corinna Vinschen Please, send mails
regarding Cygwin to
Cygwin Developer
mailto:cygwin at cygwin dot com
Red Hat, Inc.
--- gavin bowlby <gavin_bowlby@yahoo.com> wrote:
> $ uname -a
> CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
> 12:10 i686 unknown unknown
> Cygwin
>
> Windows 2K box.
>
> Process A creates Process B.
>
> I kill Process B with a "kill -9 <process B's pid>"
>
> Process A then does a:
>
> sid = getpgid(pid));
>
> pid is set to process B's pid
>
> sid is not returned as -1, even though process B no
> longer exists, as can be seen with a "ps" command.
> This occurs repeatedly.
>
> Is this correct behavior?
>
> Regards,
>
> Gavin Bowlby
>
> gavin_bowlby@yahoo.com
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms,
> and more
> http://tax.yahoo.com
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
2003-04-02 3:06 gavin bowlby
@ 2003-04-02 9:30 ` Corinna Vinschen
0 siblings, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2003-04-02 9:30 UTC (permalink / raw)
To: cygwin
On Tue, Apr 01, 2003 at 07:06:45PM -0800, gavin bowlby wrote:
> $ uname -a
> CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
> 12:10 i686 unknown unknown
> Cygwin
Could you test with 1.3.22 please?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists
@ 2003-04-02 3:06 gavin bowlby
2003-04-02 9:30 ` Corinna Vinschen
0 siblings, 1 reply; 8+ messages in thread
From: gavin bowlby @ 2003-04-02 3:06 UTC (permalink / raw)
To: cygwin
$ uname -a
CYGWIN_NT-5.0 reptilicus 1.3.20(0.73/3/2) 2003-02-08
12:10 i686 unknown unknown
Cygwin
Windows 2K box.
Process A creates Process B.
I kill Process B with a "kill -9 <process B's pid>"
Process A then does a:
sid = getpgid(pid));
pid is set to process B's pid
sid is not returned as -1, even though process B no
longer exists, as can be seen with a "ps" command.
This occurs repeatedly.
Is this correct behavior?
Regards,
Gavin Bowlby
gavin_bowlby@yahoo.com
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-04-03 3:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-03 3:00 1.3.20 : getpgid returns pid != -1 when specified pid no longer exists gavin bowlby
2003-04-03 3:05 ` gavin bowlby
2003-04-03 3:19 ` Christopher Faylor
-- strict thread matches above, loose matches on Subject: below --
2003-04-02 20:20 gavin bowlby
2003-04-02 20:23 ` gavin bowlby
2003-04-02 23:24 ` Christopher Faylor
2003-04-02 3:06 gavin bowlby
2003-04-02 9:30 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).