Since cygwin1.dll version 1.5.20 I get bash processes became <defunct>
sometimes after SSH session disconnects. For example, today there was
a network problem and my SSH session got broken, after I reconnected,
there was 1 <defunct> process. Sometimes this does not happen. All
components I am using are updated to latest release available.
This is something to show what is happening:
shadow@loshadka:~$ ps -a
PID PPID PGID WINPID TTY UID STIME COMMAND
1588 1 1588 1588 ? 18 Aug 29 /usr/bin/cygrunsrv
1640 1588 1640 1488 ? 18 Aug 29 /usr/sbin/sshd
1532 1640 1532 1228 ? 18 12:37:45 <defunct>
1576 1640 1576 1676 ? 18 12:22:09 <defunct>
I 1136 1 1136 1748 3 1000 14:11:20 /usr/bin/bash
1496 1516 1496 1568 4 1000 16:58:58 /usr/bin/bash
1088 1496 1088 1644 4 1000 17:08:08 /usr/bin/ps
shadow@loshadka:~$ kill -9 1136
-bash: kill: (1136) - No such process
shadow@loshadka:~$ /bin/kill.exe -f 1136
kill: couldn't open pid 1748
shadow@loshadka:~$ /bin/kill.exe -f 1748
kill: couldn't open pid 1748
shadow@loshadka:~$ kill -9 1532
-bash: kill: (1532) - No such process
shadow@loshadka:~$ /bin/kill.exe -f 1532
kill: couldn't open pid 1228
shadow@loshadka:~$ /bin/kill.exe -f 1228
kill: couldn't open pid 1228
shadow@loshadka:~$ ps -W |grep -e bash -e defunct
1532 1640 1532 1228 ? 18 12:37:45 <defunct>
1576 1640 1576 1676 ? 18 12:22:09 <defunct>
I 1136 1 1136 1748 3 1000 14:11:20 /usr/bin/bash
1496 1516 1496 1568 4 1000 16:58:58 /usr/bin/bash
shadow@loshadka:~$ pslist |grep bash
bash 1620 8 4 111 2208 0:00:00.350 5:48:55.546
bash 588 8 4 111 2208 0:00:00.120 5:04:13.920
bash 1568 8 4 123 2236 0:00:00.310 0:23:27.237
bash 1524 8 2 72 1532 0:00:00.040 0:00:00.070
bash 1664 8 2 55 1456 0:00:00.030 0:00:00.040
Note: pslist is an external utility from sysinternals.
shadow@loshadka:~$ type pslist
pslist is /d/tools/bin/pslist
I also want to mention that before 1.5.20 bash processes just remained
in memory and I had to kill them manually. It would be much better if
they'd got killed upon SSH disconnection, like it happens in normal
unix environment.