Browse Source

When vfork is not available and we have an MMU, then use fork()
-Erik

Eric Andersen 23 years ago
parent
commit
e4a1f78e73
3 changed files with 21 additions and 7 deletions
  1. 6 0
      libc/stdio/popen.c
  2. 6 0
      libc/stdlib/system.c
  3. 9 7
      libc/stdlib/unix_grantpt.c

+ 6 - 0
libc/stdio/popen.c

@@ -12,6 +12,12 @@
 #include <sys/wait.h>
 #include <errno.h>
 
+/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
+#include <sys/syscall.h>
+#if ! defined __NR_vfork && defined __UCLIBC_HAS_MMU__ 
+#define vfork fork	
+#endif
+
 FILE *popen (const char *command, const char *mode)
 {
 	FILE *fp;

+ 6 - 0
libc/stdlib/system.c

@@ -4,6 +4,12 @@
 #include <unistd.h>
 #include <sys/wait.h>
 
+/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
+#include <sys/syscall.h>
+#if ! defined __NR_vfork && defined __UCLIBC_HAS_MMU__ 
+#define vfork fork	
+#endif
+
 int __libc_system(command)
 char *command;
 {

+ 9 - 7
libc/stdlib/unix_grantpt.c

@@ -28,9 +28,15 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
-
 #include "pty-private.h"
 
+
+/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
+#include <sys/syscall.h>
+#if ! defined __NR_vfork && defined __UCLIBC_HAS_MMU__ 
+#define vfork fork	
+#endif
+
 extern int ptsname_r (int fd, char *buf, size_t buflen);
 
 /* Return the result of ptsname_r in the buffer pointed to by PTS,
@@ -140,11 +146,7 @@ grantpt (int fd)
   /* We have to use the helper program.  */
  helper:
 
-#ifdef __UCLIBC_HAS_MMU__
-  pid = fork ();
-#else
   pid = vfork ();
-#endif
   if (pid == -1)
     goto cleanup;
   else if (pid == 0)
@@ -156,10 +158,10 @@ grantpt (int fd)
       /* We pase the master pseudo terminal as file descriptor PTY_FILENO.  */
       if (fd != PTY_FILENO)
 	if (dup2 (fd, PTY_FILENO) < 0)
-	  exit (FAIL_EBADF);
+	  _exit (FAIL_EBADF);
 
       execle (_PATH_PT_CHOWN, _PATH_PT_CHOWN, NULL, NULL);
-      exit (FAIL_EXEC);
+      _exit (FAIL_EXEC);
     }
   else
     {