Recently, I find my WSL (ZSHELL) cost much CPU resource(around 35%) via the Windows resource manager.
Then I try to find out and solve this problem as follows:
~ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar28 ? 00:00:00 /init ro
root 3 1 0 Mar28 tty1 00:00:00 /init ro
mbinary 4 3 0 Mar28 tty1 00:00:12 -zsh
mbinary 48 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 66 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 173 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 225 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 431 1 0 09:45 tty1 00:00:00 [awk] <defunct>
root 6845 1 0 09:53 tty2 00:00:00 /init ro
mbinary 6846 6845 0 09:53 tty2 00:00:04 -zsh
mbinary 7419 6846 0 10:03 tty2 00:00:00 python3
mbinary 7455 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7522 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7559 1 0 14:43 tty1 00:00:00 [awk] <defunct>
mbinary 7587 1 0 14:48 tty1 00:00:00 [awk] <defunct>
mbinary 7595 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7604 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7643 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7666 1 97 15:03 tty1 00:00:21 -zsh
mbinary 7670 7666 0 15:03 tty1 00:00:00 [awk] <defunct>
mbinary 7699 4 0 15:03 tty1 00:00:00 ps -ef
➜ ~ sudo kill -9 1
➜ ~ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar28 ? 00:00:00 /init ro
root 3 1 0 Mar28 tty1 00:00:00 /init ro
mbinary 4 3 0 Mar28 tty1 00:00:12 -zsh
mbinary 48 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 66 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 173 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 225 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 431 1 0 09:45 tty1 00:00:00 [awk] <defunct>
root 6845 1 0 09:53 tty2 00:00:00 /init ro
mbinary 6846 6845 0 09:53 tty2 00:00:04 -zsh
mbinary 7419 6846 0 10:03 tty2 00:00:00 python3
mbinary 7455 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7522 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7559 1 0 14:43 tty1 00:00:00 [awk] <defunct>
mbinary 7587 1 0 14:48 tty1 00:00:00 [awk] <defunct>
mbinary 7595 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7604 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7643 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7666 1 99 15:03 tty1 00:00:25 -zsh
mbinary 7670 7666 0 15:03 tty1 00:00:00 [awk] <defunct>
mbinary 7712 4 0 15:03 tty1 00:00:00 ps -ef
It doesn't work.
I found that the zombie processes awk
occur after I use the command z
.
Info:
Windows 10: 1809
WSL: Ubuntu 1804
Best Answer
I am running Microsoft Windows 10 Pro (64-bit), Version 10.0.18362 and I still get rogue zsh processes. This function kills the rogue zsh processes.
killzshs(){ps ax -o pid,command,ppid | grep '.*zsh.*\s1$' | awk '{print $1}' | xargs kill -9}
Then call
killzshs
or put the function in your dotfiles.