Zombie process systemd-escape... bug in parent process udisksd?

sudo top
Tasks: 476 total, 1 running, 474 sleeping, 0 stopped, 1 zombie

sudo ps aux | awk '$8 ~ /^[Zz]/'
root 4900 0.0 0.0 0 0 ? Z 21:20 0:00 [systemd-escape] <defunct>

ps -A -ostat,pid,ppid | grep -e '[zZ]'
Z 4900 2800

sudo ps aux
root 4900 0.0 0.0 0 0 ? Z 21:20 0:00 [systemd-escape] <defunct>

root 2800 0.0 0.1 708380 12640 ? Ssl 21:20 0:00 /usr/lib/udisks2/udisksd

1 Like
1 Like

Let's try something:

sudo apt install lldb

sudo lldb -p 2800

expr (int)::waitpid(4900, NULL, 0)

exit

sudo top
Tasks: 507 total, 2 running, 505 sleeping, 0 stopped, 0 zombie

And I guess that's how you kill a zombie process without having to kill the parent process.

1 Like

I'm going to try to create a one-line bash script that'll do all of the above. I'll likely need some help, as I've only ever created one bash script to date, and it's not even working perfectly yet (I'm still working on it).

Specifically, I'll need a regex method of extracting the parent ID and child ID from:
ps -A -ostat,pid,ppid | grep -e '[zZ]'
Z 4900 2800

so I can drop them into the:
sudo lldb -p 2800
expr (int)::waitpid(4900, NULL, 0)
... commands.

I envision setting it up so it runs from a keyboard shortcut (as I've done for memory recovery, updates, ZFS SCRUB of the hard drives and clearing old ZFS snapshots), so if there are no zombie processes, it'd note that and exit.

Or it could be set up to run periodically via cron.

1 Like

You are more advanced than me - I have never scripted. (Except following other tutorials, such as how to extract M$ Licence key for Windows when getting ready for reinstall without having to search for documentation!)

1 Like

I think I've got it:

sudo ps -A -o stat,ppid,pid | grep -e '[zZ]' | awk '{print $2}'
That returns the ppid.

sudo ps -A -o stat,ppid,pid | grep -e '[zZ]' | awk '{print $3}'
That returns the pid.

So we'd modify the lines above:
sudo apt install lldb
sudo lldb -p 2800
expr (int)::waitpid(4900, NULL, 0)
exit

To something like:
sudo apt install lldb; sudo lldb -p $(sudo ps -A -o stat,ppid,pid | grep -e '[zZ]' | awk '{print $2}');expr (int)::waitpid($(sudo ps -A -o stat,ppid,pid | grep -e '[zZ]' | awk '{print $3}'), NULL, 0);exit

That doesn't work yet... we have to have some way of piping the commands to lldb, since it runs as a child process in Terminal.

[EDIT]
We might have to use sudo lldb --repl -p... that puts lldb into REPL (Read-Eval-Print-Loop) mode to allow programmatic interactivity with lldb.

Or sudo lldb --batch -p to put lldb into batch mode with the commands already set up and ready to run.