From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17588 invoked from network); 8 Jun 2001 04:51:55 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Jun 2001 04:51:55 -0000 Received: (qmail 4328 invoked by alias); 8 Jun 2001 04:51:19 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14796 Received: (qmail 4287 invoked from network); 8 Jun 2001 04:51:13 -0000 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to lantern@shell10.ba.best.com using -f From: "Bart Schaefer" Message-Id: <1010608045050.ZM1210@candle.brasslantern.com> Date: Fri, 8 Jun 2001 04:50:49 +0000 In-Reply-To: <20010605141619.A36532@lizzy.bugworks.com> Comments: In reply to Jos Backus "Re: 4.0.1: problem with sourcing on Solaris" (Jun 5, 2:16pm) References: <20010604143759.A91833@lizzy.bugworks.com> <1010605061126.ZM4201@candle.brasslantern.com> <20010605141619.A36532@lizzy.bugworks.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Jos Backus , zsh-workers@sunsite.dk Subject: Re: 4.0.1: problem with sourcing on Solaris MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 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