In bash, if I run kill %1
, it kills a backgrounded command in the current shell (the most recent one, I believe).
Is there an equivalent of this in fish? I haven't been able to find it online in a bit of web searching.
I'm not sure if I did it wrong, but
$ ps
PID TTY TIME CMD
73911 pts/5 00:00:00 fish
73976 pts/5 00:00:00 ps
$ sleep 100
^Z⏎
$ kill %1
$ ps
PID TTY TIME CMD
73911 pts/5 00:00:00 fish
74029 pts/5 00:00:00 sleep
74121 pts/5 00:00:00 ps
Best Answer
Your command has worked, but because the job is stopped it has not responded to the signal.
From your example where it didn't seem to work, try continuing the process with
fg
orbg
, or forcibly terminate the process withkill -SIGKILL %1
, and it will exit.kill %1
works immediately in bash and zsh because it is a builtin command in these shells and sendsSIGCONT
in addition toSIGTERM
(or the specified signal).