0

I executed a command which I then disowned so that it can continue to run in the background, even if I closed the terminal.

The command is:

badblocks -v -s -w /dev/sdb > badblocks_result.txt 2>&1 & disown

The command is running with a PID of 1146.

How do I bring that back into the current terminal that I am using if I would like to CTRL-C the command and not kill it using the PID?

AdminBee
  • 22,803

1 Answers1

0

My solution would be to use the following answer https://superuser.com/a/1231033/432690

The answer was supplied by @Kamil Maciorowski comment.

"If I would like to CTRL-C the command and not kill it using the PID" – What is the point?

Upon Ctrl+c badblocks would get SIGINT just like from kill -s INT 1146, it couldn't tell the difference. In general Ctrl+c sends SIGINT to a process group, so if you target just one process with kill -s INT, something may misbehave (example); but here there should be no issues, badblocks is most likely the only process in its process group.

Why do you want Ctrl+c and not kill? If you really want: reptyr.

AdminBee
  • 22,803