14

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

  • 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
21

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.

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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