5

If I execute the following command in LXTerminal:

gnome-terminal & 

gnome-terminal gets opened. But as soon as I close the LXTerminal, gnome-terminal will be closed as well because it's a child process. Is there any way to open the second process independently?

0

2 Answers 2

7

It's not possible to start a process without it being the child. When you execute an external command, under the hood the shell calls fork() followed by execvp(). You can prevent it from getting killed when the parent shell dies.

One way is to use nohup:

nohup gnome-terminal & 

Another option if you are using bash is to disown the process:

gnome-terminal & disown 
1
  • nohup didn't seem to work for me but disown did. Commented Jun 6, 2017 at 14:27
-1

Yes just try to open this as follow.

$ sudo gnome-terminal & 

So that both the terminals are available to you for work. But remember not to close the Parent terminal, as it will close the child terinal.

I is possible with nohup.

$ nohup gnome-terminal & $ exit 
7
  • 4
    I think you missed the point of the question and even added an unnecessary sudo. Commented Nov 16, 2013 at 5:55
  • It is not possible to open child process independently. You are asking to kill the parent process, how can a child process will survive Meysam. Commented Nov 16, 2013 at 6:00
  • "It is not possible to open child process independently". Are you definitely sure it's not possible? Commented Nov 16, 2013 at 6:02
  • Yes i am definitely sure as per my knowledge. You can use that terminal but can not close that terminal. Commented Nov 16, 2013 at 6:04
  • @Meysam - all processes are children, with the exception of init. Commented Nov 16, 2013 at 6:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.