I'm running the following command in Linux:
sudo ./tftpCommand &
where my executable tftpCommand file simply gets/puts a data file which sometimes does not exist. I want to be able to stop the tftp command that was spawned in the subshell before it automatically times out.
Using something like kill $(jobs -p)
shows that the subshell has been terminated but the tftp still runs -- I know this because several seconds later it prints to the shell that it can't find the file to transfer.
QUESTION: How do I ensure that the tftp command is killed alongside the subshell that runs it?
Thanks!
I've found a solution to my problem:
use pkill -c tftp
to kill any current tftp commands.
I figured this out by using ps x -o "%p %r %c"
You can use a similar technique for any of the command names in the COMMAND column (corresponding to the %c and -c ) to kill other processes.
Hope that helps anyone else who stumbles upon the same problem!