1.3.3-2: ps.exe bug for processes with a zero ppid

Robert Legros robert_legros@yahoo.com
Wed Oct 3 05:54:00 GMT 2001


Hello,

There is a follow up to the bug "1.3.3-2: Process
creation is possible with ppid = 0 and pgid = 0"
< http://cygwin.com/ml/cygwin/2001-10/msg00109.html >.

'ps.exe' does not behave correctly with such
processes. This is due to the fact that in the code,
there is a criteria to see if a process is a Cygwin
one or a Windows one. And that criteria is precisely
(p-ppid != 0) !.

I have written a patch for 'ps.exe'. It is more a hack
than a real bug correction, but it works. In fact the
real bug correction must be done somewhere in the
process creation routines inside 'cygwin1.dll'. This
patch is to be found in attachment.

For those who should like to install this correction,
here is how to do it. In attachment is the corrected
version of 'ps.cc'. Do compile it using the following
command :
        gcc -O2 -s ps.cc -o ps.exe
And then install it :
        cp -p ps.exe /bin

Best Regards,


=====
Robert Legros
south Brussels, Belgium
robert_legros@yahoo.com

__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com
diff -upr cygwin-1.3.3-2/winsup/utils/ps.cc cygwin-1.3.3-2.new/winsup/utils/ps.cc
--- cygwin-1.3.3-2/winsup/utils/ps.cc	Tue May  8 05:55:40 2001
+++ cygwin-1.3.3-2.new/winsup/utils/ps.cc	Wed Oct  3 14:11:24 2001
@@ -271,7 +271,7 @@ main (int argc, char *argv[])
       char pname[MAX_PATH];
       if (p->process_state & (PID_ZOMBIE | PID_EXITED))
         strcpy (pname, "<defunct>");
-      else if (p->ppid)
+      else if (p->ctty != -1) /* THIS IS HACK ! REALLY ! */
 	{
 	  char *s;
 	  pname[0] = '\0';


More information about the Cygwin mailing list