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

Re: [RFC][PATCH] Add zrestart()



On Mon, Apr 26, 2021 at 12:30 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> > What kind of approach would be acceptable?
>
> I think you've basically run into the halting problem here

Consequently we need to decide collectively whether we're just
rejecting "zrestart" as impossible, or if there's a sub-optimal
solution we can agree on.  I suspect that executing the entire startup
twice in order to be sure it'll work once, is not one we'll agree on.

Not really a solution, but an interesting (?) observation:

If you start an interactive shell in the background, it will stop when
it tries to print the first prompt:

% echo $$
277859
% Src/zsh -f &
[1] 277861
%
[1]  + suspended (tty output)  Src/zsh -f

You can then do:

% exec fg
[1]  + continued  Src/zsh -f
% echo $$
277861
%

Now you're at the prompt for the previously backgrounded shell.  If
you exit from that, the parent is gone.

So if you had some way to detect that a backgrounded shell had
actually reached the PS1 prompt, you could cause the parent shell to
replace itself.




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