Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.sources.d Subject: Re: Perl on Microport 286: can't find library routines Message-ID: <2420@auspex.auspex.com> Date: 7 Sep 89 17:42:28 GMT References: <2869@splut.conmicro.com> <9257@attctc.Dallas.TX.US> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 99 > 2) Interactive Unix does not understand "lstat()", so I just wrote a > message to stderr, and invoked "stat()" instead (probably wrong -- > please correct my patch here!). Why bother with the message to "stderr"? Elsewhere in "perl", the #ifdef symbol SYMLINK is used to control code that is to be included only on systems that understand standard symlinks, including support for "lstat()". It appears that it was omitted in one case in "doio.c". Try this: *** doio.c.dist Tue Sep 5 13:16:55 1989 --- doio.c Tue Sep 5 13:23:38 1989 *************** *** 457,465 **** --- 457,467 ---- else { str_sset(statname,ary->ary_array[sp]); statstab = Nullstab; + #ifdef SYMLINK if (arg->arg_type == O_LSTAT) i = lstat(str_get(statname),&statcache); else + #endif i = stat(str_get(statname),&statcache); if (i < 0) max = 0; >As far as dup2() and rename(), they may not be provided -- rename can be >built out of a link() and an unlink() call sequence, And is, in fact, appears to be so built if the #ifdef symbol RENAME isn't defined. The Configure script should arrange to define this iff "rename" appears in your "libc"; presumably, something went wrong. Try manually changing the "#define RENAME" line to "#undef RENAME" in "config.h". >but I don't remember the details about dup2(). The problem here is that "dup2()" came with V7 and was inherited by BSD, but wasn't picked up by S3/S5. It did end up in POSIX, though, and S5R3 picked it up from there. If you have an 80386-based machine, you presumably have S5R3, so this is not a problem; if you have an 80286-based machine, as I think the original poster did, your UNIX is probably S5R2-based, so you lose. You can consider this more of the "this may not work on 16-bit machines" item, if you want.... However, if you don't have "dup2()", you probably have "fcntl()", and you can use "close()" followed by "fcntl(..., F_DUPFD, ...)" to achieve the same effect. In fact, on all modern UNIXes (4.xBSD for x >= 2, System V Release x for x >= 3), you have both. Try the following patch: *** util.c.dist Tue Sep 5 13:17:27 1989 --- util.c Thu Sep 7 10:37:09 1989 *************** *** 12,17 **** --- 12,21 ---- #include "perl.h" #include "errno.h" + #ifdef FCNTL + # include + #endif + #ifdef VARARGS # include #endif *************** *** 1001,1008 **** this = !this; /* swap this and that */ that = !this; close(p[that]); ! if (p[this] != (*mode == 'r')) { ! dup2(p[this], *mode == 'r'); close(p[this]); } if (doexec) { --- 1005,1017 ---- this = !this; /* swap this and that */ that = !this; close(p[that]); ! if (p[this] != this) { ! #ifdef FCNTL ! close(this); ! fcntl(p[this], F_DUPFD, this); ! #else ! dup2(p[this], this); ! #endif close(p[this]); } if (doexec) { (untested, but I think it should work - it assumes that "*mode" is either equal to 'r' or 'w', which appears to be the case for all calls to "mypopen"). Note: "#include " is correct, even for 4.3BSD, and I think for 4.2BSD as well; ignore the manual page's insistence that you include , it leads to less portable code which is no better than the more-portable code.