X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/1b929d2579bbd362e094f1087776a67dbbb8afea..0114e17e668a921c9050d5743943c16a9cee5f37:/src/sysdep.c diff --git a/src/sysdep.c b/src/sysdep.c index 2bbdf2640f..cda2b8f3a4 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -115,14 +115,7 @@ extern char *sys_errlist[]; #include #include "systty.h" - -#ifdef BSD -#ifdef BSD4_1 -#include -#else /* not 4.1 */ -#include -#endif /* not 4.1 */ -#endif /* BSD */ +#include "syswait.h" #ifdef BROKEN_TIOCGWINSZ #undef TIOCGWINSZ @@ -571,11 +564,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 +958,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 +1221,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 +1230,7 @@ init_sys_modes () init_sigio (); } #endif /* F_GETOWN */ +#endif /* F_SETOWN_BUG */ #endif /* F_SETFL */ #ifdef BSD4_1 @@ -1372,6 +1372,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 +1380,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 +2572,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 +2706,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 +2721,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,20 +2923,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); - /* Some systems allocate the buffer and the DIR all in one block. - Why in the world are we freeing this ourselves anyway? */ - if (dirp->dd_buf != (char *)(dirp + 1)) - 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 @@ -3080,6 +3084,134 @@ 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, fd; + 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; + + synch_process_alive = 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 */ + fd = sys_open("/dev/null", 2); + if (fd >= 0) + { + dup2 (fd, 0); + dup2 (fd, 1); + dup2 (fd, 2); + } + execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); + _exit (-1); /* Can't exec /bin/mkdir */ + + default: /* Parent process */ + wait_for_termination (cpid); + } + + if (synch_process_death != 0 || synch_process_retcode != 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, fd; + struct stat statbuf; + + if (stat (dpath, &statbuf) != 0) + { + /* Stat just set errno. We don't have to */ + return -1; + } + + synch_process_alive = 1; + switch (cpid = fork ()) + { + + case -1: /* Error in fork */ + return (-1); /* Errno is set already */ + + case 0: /* Child process */ + fd = sys_open("/dev/null", 2); + if (fd >= 0) + { + dup2 (fd, 0); + dup2 (fd, 1); + dup2 (fd, 2); + } + execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); + _exit (-1); /* Can't exec /bin/mkdir */ + + default: /* Parent process */ + wait_for_termination (cpid); + } + + if (synch_process_death != 0 || synch_process_retcode != 0) + { + errno = EIO; /* We don't know why, but */ + return -1; /* /bin/rmdir failed */ + } + + return 0; +} +#endif /* !HAVE_RMDIR */ + + /* Functions for VMS */ #ifdef VMS