X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/37fd7901b2e694e07267ef6999875fb31fed70ad..23524fb9509369fc89f843fbbad0a3de06bb0d1d:/src/sysdep.c diff --git a/src/sysdep.c b/src/sysdep.c index e696cb3d35..d765fa79ec 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -571,11 +571,14 @@ sys_suspend () #else #ifdef SIGTSTP -#ifdef GETPGRP_NO_ARG - EMACS_KILLPG (getpgrp (), SIGTSTP); + { +#ifdef USG + int pgrp = getpgrp (); #else - EMACS_KILLPG (getpgrp (0), SIGTSTP); + int pgrp = getpgrp (0); #endif + EMACS_KILLPG (pgrp, SIGTSTP); + } #else /* No SIGTSTP */ #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ @@ -962,9 +965,11 @@ int term_initted; /* 1 if outer tty status has been recorded */ int lmode; #endif +#ifndef F_SETOWN_BUG #ifdef F_SETOWN int old_fcntl_owner; #endif /* F_SETOWN */ +#endif /* F_SETOWN_BUG */ /* This may also be defined in stdio, but if so, this does no harm, @@ -1223,6 +1228,7 @@ init_sys_modes () } #ifdef F_SETFL +#ifndef F_SETOWN_BUG #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ if (interrupt_input) { @@ -1231,6 +1237,7 @@ init_sys_modes () init_sigio (); } #endif /* F_GETOWN */ +#endif /* F_SETOWN_BUG */ #endif /* F_SETFL */ #ifdef BSD4_1 @@ -1372,6 +1379,7 @@ reset_sys_modes () #endif #ifdef F_SETFL +#ifndef F_SETOWN_BUG #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ if (interrupt_input) { @@ -1379,6 +1387,7 @@ reset_sys_modes () fcntl (0, F_SETOWN, old_fcntl_owner); } #endif /* F_SETOWN */ +#endif /* F_SETOWN_BUG */ #endif /* F_SETFL */ #ifdef BSD4_1 if (interrupt_input) @@ -2570,6 +2579,19 @@ sys_write (fildes, buf, nbyte) #endif /* INTERRUPTIBLE_IO */ +#ifndef HAVE_VFORK + +/* + * Substitute fork for vfork on USG flavors. + */ + +vfork () +{ + return (fork ()); +} + +#endif /* not HAVE_VFORK */ + #ifdef USG /* * All of the following are for USG. @@ -2691,8 +2713,8 @@ getwd (pathname) #ifndef HAVE_RENAME rename (from, to) - char *from; - char *to; + const char *from; + const char *to; { if (access (from, 0) == 0) { @@ -2706,19 +2728,6 @@ rename (from, to) #endif -#ifndef HAVE_VFORK - -/* - * Substitute fork for vfork on USG flavors. - */ - -vfork () -{ - return (fork ()); -} - -#endif /* not HAVE_VFORK */ - #ifdef MISSING_UTIMES /* HPUX (among others) sets HAVE_TIMEVAL but does not implement utimes. */ @@ -2921,16 +2930,22 @@ char *sys_siglist[NSIG + 1] = #include -#ifndef AIX +#ifndef HAVE_CLOSEDIR int closedir (dirp) register DIR *dirp; /* stream from opendir */ { sys_close (dirp->dd_fd); - xfree ((char *) dirp->dd_buf); /* directory block defined in */ + + /* Some systems (like Solaris) allocate the buffer and the DIR all + in one block. Why in the world are we freeing this ourselves + anyway? */ +#if ! (defined (sun) && defined (USG5_4)) + xfree ((char *) dirp->dd_buf); /* directory block defined in */ +#endif xfree ((char *) dirp); } -#endif /* not AIX */ +#endif /* not HAVE_CLOSEDIR */ #endif /* SYSV_SYSTEM_DIR */ #ifdef NONSYSTEM_DIR_LIBRARY @@ -3076,6 +3091,118 @@ readdirver (dirp) #endif /* VMS */ #endif /* NONSYSTEM_DIR_LIBRARY */ + + +/* mkdir and rmdir functions, for systems which don't have them. */ + +#ifndef HAVE_MKDIR +/* + * Written by Robert Rother, Mariah Corporation, August 1985. + * + * If you want it, it's yours. All I ask in return is that if you + * figure out how to do this in a Bourne Shell script you send me + * a copy. + * sdcsvax!rmr or rmr@uscd + * + * Severely hacked over by John Gilmore to make a 4.2BSD compatible + * subroutine. 11Mar86; hoptoad!gnu + * + * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, + * subroutine didn't return EEXIST. It does now. + */ + +/* + * Make a directory. + */ +int +mkdir (dpath, dmode) + char *dpath; + int dmode; +{ + int cpid, status; + struct stat statbuf; + + if (stat (dpath, &statbuf) == 0) + { + errno = EEXIST; /* Stat worked, so it already exists */ + return -1; + } + + /* If stat fails for a reason other than non-existence, return error */ + if (errno != ENOENT) + return -1; + + switch (cpid = fork ()) + { + + case -1: /* Error in fork() */ + return (-1); /* Errno is set already */ + + case 0: /* Child process */ + /* + * Cheap hack to set mode of new directory. Since this + * child process is going away anyway, we zap its umask. + * FIXME, this won't suffice to set SUID, SGID, etc. on this + * directory. Does anybody care? + */ + status = umask (0); /* Get current umask */ + status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ + execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); + _exit (-1); /* Can't exec /bin/mkdir */ + + default: /* Parent process */ + while (cpid != wait (&status)); /* Wait for kid to finish */ + } + + if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) + { + errno = EIO; /* We don't know why, but */ + return -1; /* /bin/mkdir failed */ + } + + return 0; +} +#endif /* not HAVE_MKDIR */ + +#ifndef HAVE_RMDIR +int +rmdir (dpath) + char *dpath; +{ + int cpid, status; + struct stat statbuf; + + if (stat (dpath, &statbuf) != 0) + { + /* Stat just set errno. We don't have to */ + return -1; + } + + switch (cpid = fork ()) + { + + case -1: /* Error in fork() */ + return (-1); /* Errno is set already */ + + case 0: /* Child process */ + execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); + _exit (-1); /* Can't exec /bin/mkdir */ + + default: /* Parent process */ + while (cpid != wait (&status)); /* Wait for kid to finish */ + } + + if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) + { + errno = EIO; /* We don't know why, but */ + return -1; /* /bin/mkdir failed */ + } + + return 0; +} +#endif /* !HAVE_RMDIR */ + + /* Functions for VMS */ #ifdef VMS