script spawn via atd leaves a process stuck in wait

I have a bash script which is run via at, I run it like
echo "bash /path/to/my/" | at -M now because I want it
to run detached.

When the script is spawned, immediately I see 2 instances (ps), and
even after my script completes successfully, another instance just
wont terminate. It will get reparented to pid 1 and just keeps doing
wait ( strace shows wait4(-1...).

I am not able to figure out why or how this second instance is forked!
When I run the script without at, I don’t see the second process.
Any hints/tips to debug this ?


Go to Source
Author: vyom