From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Using "source" in a function breaks job control
Date: Wed, 22 Apr 2015 21:55:39 -0700 [thread overview]
Message-ID: <150422215539.ZM14251@torch.brasslantern.com> (raw)
In-Reply-To: <20150422222627.1f6154e9@ntlworld.com>
On Apr 22, 10:26pm, Peter Stephenson wrote:
} Subject: Re: Using "source" in a function breaks job control
}
} > 1. echo true > /tmp/foo.zsh
} > 2. vi() { source /tmp/foo.zsh; vim -u NONE -N; }
} > 3. Run "vi"
} > 4. In Vim, press Ctrl-Z to put it into the background.
} > 5. Execute "fg".
} >
} > It should bring back "vim", but does not.
}
} I'm not going to get any further with this tonight, but using a build to
} instrument process group handling I posted a few weeks ago it seems that
} in the failing case the terminal doesn't get reattached to the vim
} process when the shell function is brought to the foreground.
It's not the "."/"source" command itself that's the problem, because it
works fine as long as the sourced file does not execute any commands.
vi() { source =(<<<'# Nothing here'); vim -u NONE -N }
suspends/restarts fine.
} In the failing case,
}
} There's no attachtty to 21065. Handling of SIGCONT within the subshell?
I don't think so ... the fact that it prints
zsh: running
when you suspend it, indicates that pn->status == SP_RUNNING when passing
through printjob(). Also (though perhaps not definitive), a TRAPCONT()
handler does not fire in the subshell.
It behaves differently (but still wrong) if the "source" file runs an
external command:
torch% vi() { source =(<<<'/bin/true'); vim -u NONE -N }
torch% vi
zsh: suspended
torch% fg
[4] continued
torch%
So there it believes WIFSTOPPED(pn->status) is true, but it still brings
the wrong job into the foreground. (Actually there's a race condition
here, if I "watch thisjob" with gdb I sometimes get "zsh: running" for
an external command.)
Finally you'll note that it has lost the jobtext in the failing case
above, but in the successful case:
torch% vi() { source =(<<<'# /bin/true'); vim -u NONE -N }
torch% vi
zsh: suspended vi
torch%
It has something to do with tracking the job table.
next prev parent reply other threads:[~2015-04-23 4:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-22 18:11 Daniel Hahler
2015-04-22 20:41 ` Peter Stephenson
2015-04-22 21:26 ` Peter Stephenson
2015-04-23 4:55 ` Bart Schaefer [this message]
2015-04-23 20:13 ` Peter Stephenson
2015-04-24 6:22 ` Bart Schaefer
2015-04-24 15:25 ` Peter Stephenson
2015-04-24 15:43 ` Peter Stephenson
2015-04-24 16:21 ` Bart Schaefer
2015-04-27 17:29 ` Peter Stephenson
2015-04-28 10:18 ` Peter Stephenson
2015-04-28 15:57 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150422215539.ZM14251@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).