Subject: Re: howto register process
From: Brian Dessent <[email-masked]>
To: [email-masked]
Date: Thu, 11 Nov 2004 16:29:19 -0800

Kamen TOMOV wrote:

> The parent process is started as a windows server. Then it executes
> cygwin's fork. When I try to kill any of these with kill() it returns
> "No such pid".

Are you sure you're not confusing Cygwin PIDs with Win32 PIDs?  In order
to make the fork() magic work, Cygwin maintains its own PIDs in parallel
to the actual windows PID.  All the Cygwin functions that take PIDs as
arguments expect Cygwin PIDs, and won't work if you give the windows
PID.  Example, my output of "ps -a" shows the following:

 PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
4340       1    4340       4340  con 1003 16:13:34 /usr/bin/rxvt
3548    4340    3548       7768    0 1003 16:13:34 /usr/bin/bash
4320       1    4320       4320    ?   18 16:13:39 /usr/bin/cygrunsrv
6684    4320    6684       5772    ?   18 16:13:39 /usr/sbin/cron
5824       1    5824       5824    ? 1003 16:13:40 /usr/bin/cygrunsrv
7752       1    7752       7752    ?   18 16:13:40 /usr/bin/cygrunsrv
5116       1    5116       5116    ?   18 16:13:40 /usr/bin/cygrunsrv
6832    5116    6832        216    ?   18 16:13:40 /usr/sbin/sshd
7928    5824    7928       7212    ? 1003 16:13:40 /usr/bin/autossh
2560    7752    2560       6760    ?   18 16:13:40 /usr/sbin/cygserver
4992    7928    7928       7900    ? 1003 16:13:40 /usr/bin/ssh
6896       1    6896       6896  con 1003 16:13:50 /usr/bin/rxvt
 164    6896     164       5452    1 1003 16:13:50 /usr/bin/bash
5984    3548    5984       2124    0 1003 16:13:59 /usr/bin/ssh
6628     164    6628       2432    1 1003 16:25:39 /usr/bin/ps

As you can see, PID and WINPID are sometimes the same, but often not.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/