Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: exec



On 6/3/24 10:42 AM, Ray Andrews wrote:


On 2024-06-03 07:17, Mark J. Reed wrote:
The *exec* builtin replaces the running shell with whatever program you run.  The point is to avoid clogging the process table with shells that are just hanging out waiting to do nothing but exit as soon as their child process finishes.
I get that.


In your case, the script exists to set things up in the environment and then run xfce4-session; there's nothing for it to do after xfce4-session completes, so it uses *exec* to tidy up.

Sure.  But then what?
nothing, the process was replaced with xfce-session.

 I understand that if a script or function has nothing more to do, it may as well pre-kill itself. But the difference is that 'exec' kills the entire terminal, it doesn't just return to the prompt in a more efficient way
How would it return to the prompt of a shell/process that was replaced with another process?

when you have a `terminal -> shell' and you run exit/^D the terminal no longer has a child process and exits.
when you have a `terminal -> shell that does exec -> utility' and utility exits, the terminal no longer has a child process and exits.





Messages sorted by: Reverse Date, Date, Thread, Author