Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 4.0.1: problem with sourcing on Solaris
- X-seq: zsh-workers 14796
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Jos Backus <josb@xxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: 4.0.1: problem with sourcing on Solaris
- Date: Fri, 8 Jun 2001 04:50:49 +0000
- In-reply-to: <20010605141619.A36532@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20010604143759.A91833@xxxxxxxxxxxxxxxxxx> <1010605061126.ZM4201@xxxxxxxxxxxxxxxxxxxxxxx> <20010605141619.A36532@xxxxxxxxxxxxxxxxxx>
On Jun 5, 2:16pm, Jos Backus wrote:
} Subject: Re: 4.0.1: problem with sourcing on Solaris
}
} Here's a clue: for some reason, after re-running configure (because
} I changed a couple of entries in config.modules), BROKEN_KILL_ESRCH
} got define'd. When defined, I see the problem; when I undefine
} BROKEN_KILL_ESRCH (the default), the shell works fine. I'm wondering
} how this could end up being define'd...
It could end up being defined because the configure test for it is bad.
pid=getpid() + 10000;
ret=kill(pid, 0);
If a process whose PID is 10000 more than the current PID happens to be
running, then the test returns the wrong result.
Also, if getpid() returns a sufficiently large number, pid + 10000 might
be larger than the largest possible PID, causing a (legitimate) EINVAL,
or might wrap to negative and be interpreted as a pgrp.
The ideal solution would be to fork(), wait(), and then kill(), but the
vagaries of doing a proper wait() portably are such that it may be too
messy to use in a configure test. So I suggest the following; it tries
at least 15 different PIDs (and no more than 23 of them) and concludes
BROKEN_KILL_ESRCH only if none of those give ESRCH.
The & 0xffffff is just because I'm paranoid that left-shifting a negative
number might do sign extension, causing an infinite loop. Maybe that's
not really an issue, but it's a handy way to limit the number of shifts
as well.
Index: zshconfig.ac
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/zshconfig.ac,v
retrieving revision 1.1
diff -c -r1.1 zshconfig.ac
--- zshconfig.ac 2001/06/08 03:53:13 1.1
+++ zshconfig.ac 2001/06/08 04:43:12
@@ -1377,10 +1377,9 @@
#include <errno.h>
main()
{
- int pid, ret;
- pid=getpid() + 10000;
- ret=kill(pid, 0);
- exit(ret<0 && errno!=ESRCH);
+ int pid = (getpid() + 10000) & 0xffffff;
+ while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1;
+ exit(errno!=ESRCH);
}
],
zsh_cv_sys_killesrch=yes,
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author