@bedna No, you are wrong. Try it.
The example code I’ve shown isn’t exactly what balooctl
is doing, but it is similar enough that bg
and fg
will not work on that. The shell commands bg
and fg
do not work on process IDs (“pid”), they work on “shell jobs” and they take “jobspec”:
fg [jobspec]
Resume jobspec in the foreground, and make it the current job. If jobspec is not present, the shell’s notion of the current job is used.
I’ll repeat the example shell code I wrote for completeness:
( while true; do echo test; sleep 3; done & )
The backgrounding of the task using the &
indeed creates a shell job, but it is a job inside a sub-shell and as soon as that sub-shell ends - its job management ends and you cannot create a jobspec
that addresses the job in the shell that ended.
The balooctl
case isn’t even that - its just spawned a process in the background directly using fork()
, it has no shell job and there never was a job that you could reattach to.