Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I don't understand why exit & does not work. Why does it not?

share|improve this question
3  
dummy question. I'd vote for closing it. –  poige Aug 15 '13 at 14:03
1  
But people may not find the truth on demand then :( –  Pedro Ziff Aug 15 '13 at 14:05
    
Dummy truth isn't worth finding, don't worry ;) –  poige Aug 15 '13 at 14:06
2  
But I am happy I found it, life fulfilled suddenly. :) –  Pedro Ziff Aug 15 '13 at 14:07
1  
Same reason cd / & "doesn't work" –  kojiro Aug 16 '13 at 11:20

2 Answers 2

up vote 19 down vote accepted

I think it works. But probably it doesn't do what you expect.

 $ exit &

Will create a sub-shell process, and make it run as a background job which will just finish right away.

share|improve this answer
10  
In other words, this is the "fake your own death" operator. –  Kaz Aug 15 '13 at 19:54

It does work. & forks the shell, starting a new process (you could think of it as & exit, except of course that syntax actually means something else). exit is a shell built-in that ends the shell process -- in this case the new backgrounded shell.

> exit &
[1] 1709
> ps -p 1709
  PID TTY          TIME CMD
[1]+  Done                    exit

There's your job. It's done. It worked.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.