This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
vfork patch - still no fix for segfaults:-(
- To: libc-hacker@cygnus.com
- Subject: vfork patch - still no fix for segfaults:-(
- From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Date: Fri, 15 Jan 1999 09:21:20 +0100 (CET)
Shouldn't vfork save the errno in case that it doesn't exist?
The following patch does this - but nevertheless the resulting libc is
unusable for me. I guess the Linux implementation of vfork in Linux
2.2.0pre7 is broken. Using fork instead of vfork I don't get a
problem.
Does sysdeps/unix/sysv/linux/i386/syscalls.list needs an entry for
vfork? (I know I've asked this already, so if this has been answered
in the meantime, ignore the question.)
Andreas
1999-01-15 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/vfork.c: Save and reset errno,
remember if vfork exists.
--- sysdeps/unix/sysv/linux/vfork.c.~1~ Thu Jan 14 07:33:06 1999
+++ /tmp/vfork.c.new Fri Jan 15 09:10:23 1999
@@ -27,17 +27,27 @@
#ifdef __NR_vfork
extern pid_t __syscall_vfork __P ((void));
+static int __libc_missing_vfork;
+
/* Use the system call. If it's not available, fork is close enough. */
pid_t
__vfork __P ((void))
{
- pid_t retval = INLINE_SYSCALL (vfork, 0);
-
- if (retval == (pid_t) -1 && errno == ENOSYS)
- retval = INLINE_SYSCALL (fork, 0);
+ pid_t retval;
+
+ if (!__libc_missing_vfork)
+ {
+ int saved_errno = errno;
+ retval = INLINE_SYSCALL (vfork, 0);
- return retval;
+ if (retval != (pid_t) -1 || errno != ENOSYS)
+ return retval;
+
+ __set_errno (saved_errno);
+ __libc_missing_vfork = 1;
+ }
+ return INLINE_SYSCALL (fork, 0);
}
#else
pid_t
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de