Difference between ctrl-z and in linux

0 votes

My understanding is that when you are running any command within a given shell (say bash), what's happening under the hood is that a fork system call is called, and sleep 10 is now running as a child process with the parent being the bash shell I executed the sleep.

Now, if I want to send sleep to the background, I would either do sleep 10 & or run sleep 10 and press ctrl+z so the process is sent to the background. pstree shows that using any of these options, sleep keeps being a child process of the bash shell.

Now my question is, when doing this through SSH, I noted the following: If I do: sleep 999 & and sleep 888 <- followed by a ctrl+z, and the close the ssh session, only sleep 999 & survived.

Why is this? I actually was expecting one of these:

  • both processes get terminated because the parent process is gone

  • both processes get associated to init as the parent process.


 

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
447 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
1 answer

What is the difference between ctrl z and ctrl c in command line?

Hi@akhtar, Generally, these two commands are used to ...READ MORE

answered Feb 24, 2020 in Linux Administration by MD
• 95,460 points
47,278 views
0 votes
0 answers

Difference between "system" and "exec" in Linux?

What is the difference between system and ...READ MORE

Apr 26, 2022 in Linux Administration by Edureka
• 13,690 points
545 views
0 votes
1 answer

Difference between root (/) and home directory (~) in terminal?

Root directory which is referred to as ...READ MORE

answered Jun 20, 2019 in Linux Administration by Vicky
27,567 views
0 votes
0 answers

What is the difference between ''find .'' and ''find /'' on linux command

I am solving overthewire bandit. I looked ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
419 views
0 votes
1 answer

Difference between single and double quotes in Bash

Single statements will not add anything, however ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
491 views
0 votes
1 answer

Difference between single and double quotes in Bash

Single statements will not insert anything, yet ...READ MORE

answered Jun 10, 2022 in Linux Administration by Korak
• 5,820 points
616 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Adding yes/no/cancel prompts in shell script

You can use the read command. Here's ...READ MORE

answered Mar 13, 2019 in Linux Administration by ajs3033
• 7,300 points
4,200 views
0 votes
1 answer

How to change the default shell in Linux?

1. Change the password file directly for ...READ MORE

answered May 24, 2019 in Linux Administration by Upasana
• 8,620 points
982 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP