Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: non-interactive set -m
- X-seq: zsh-workers 27134
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: non-interactive set -m
- Date: Sun, 12 Jul 2009 15:42:27 +0100
- In-reply-to: <20090711195702.52896b2a@pws-pc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <loom.20090707T205334-50@xxxxxxxxxxxxxx> <200907080858.n688wXfc030608@xxxxxxxxxxxxxx> <loom.20090708T124251-758@xxxxxxxxxxxxxx> <200907081349.n68DneSv001850@xxxxxxxxxxxxxx> <loom.20090709T170937-567@xxxxxxxxxxxxxx> <20090709212345.05cc2213@pws-pc> <loom.20090710T032337-801@xxxxxxxxxxxxxx> <loom.20090710T032943-225@xxxxxxxxxxxxxx> <20090711195702.52896b2a@pws-pc>
On Sat, 11 Jul 2009 19:57:02 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> Again, this passed a trivial smoke test. From the non-interactive case
> I think keeping SHTTY around is benign, but we're heading into
> more difficult territory.
We should make sure it's closed on an exec, however. This maybe what
the previous code was trying to do.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.169
diff -u -r1.169 exec.c
--- Src/exec.c 11 Jul 2009 19:06:52 -0000 1.169
+++ Src/exec.c 12 Jul 2009 14:38:36 -0000
@@ -595,6 +595,12 @@
* here, which should be visible to external processes.
*/
closem(FDT_XTRACE);
+#ifndef FD_CLOEXEC
+ if (SHTTY != -1) {
+ close(SHTTY);
+ SHTTY = -1;
+ }
+#endif
child_unblock();
if ((int) strlen(arg0) >= PATH_MAX) {
zerr("command too long: %s", arg0);
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.105
diff -u -r1.105 init.c
--- Src/init.c 11 Jul 2009 16:43:00 -0000 1.105
+++ Src/init.c 12 Jul 2009 14:38:36 -0000
@@ -480,8 +480,16 @@
if (SHTTY == -1) {
zsfree(ttystrname);
ttystrname = ztrdup("");
- } else if (!ttystrname) {
- ttystrname = ztrdup("/dev/tty");
+ } else {
+#ifdef FD_CLOEXEC
+ long fdflags = fcntl(SHTTY, F_GETFD, 0);
+ if (fdflags != (long)-1) {
+ fdflags |= FD_CLOEXEC;
+ fcntl(SHTTY, F_SETFD, fdflags);
+ }
+#endif
+ if (!ttystrname)
+ ttystrname = ztrdup("/dev/tty");
}
/* We will only use zle if shell is interactive, *
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author