aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-15 04:28:05 +0000
committerRichard M. Stallman1993-08-15 04:28:05 +0000
commit039f26a48fc065b90f18a92a884df46c25d92057 (patch)
treeca952dbb69ef259fda2009cc7da06afcdb255dfc /src
parent74e299845c9d6454841aa42b47d680ec5515be74 (diff)
downloademacs-039f26a48fc065b90f18a92a884df46c25d92057.tar.gz
emacs-039f26a48fc065b90f18a92a884df46c25d92057.zip
(mkdir, rmdir): Use wait_for_termination to wait.
Redirect descriptors 0...2 to /dev/null.
Diffstat (limited to 'src')
-rw-r--r--src/sysdep.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index bf770b767c0..cda2b8f3a47 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3112,7 +3112,7 @@ mkdir (dpath, dmode)
3112 char *dpath; 3112 char *dpath;
3113 int dmode; 3113 int dmode;
3114{ 3114{
3115 int cpid, status; 3115 int cpid, status, fd;
3116 struct stat statbuf; 3116 struct stat statbuf;
3117 3117
3118 if (stat (dpath, &statbuf) == 0) 3118 if (stat (dpath, &statbuf) == 0)
@@ -3125,10 +3125,11 @@ mkdir (dpath, dmode)
3125 if (errno != ENOENT) 3125 if (errno != ENOENT)
3126 return -1; 3126 return -1;
3127 3127
3128 synch_process_alive = 1;
3128 switch (cpid = fork ()) 3129 switch (cpid = fork ())
3129 { 3130 {
3130 3131
3131 case -1: /* Error in fork() */ 3132 case -1: /* Error in fork */
3132 return (-1); /* Errno is set already */ 3133 return (-1); /* Errno is set already */
3133 3134
3134 case 0: /* Child process */ 3135 case 0: /* Child process */
@@ -3140,14 +3141,21 @@ mkdir (dpath, dmode)
3140 */ 3141 */
3141 status = umask (0); /* Get current umask */ 3142 status = umask (0); /* Get current umask */
3142 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ 3143 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */
3144 fd = sys_open("/dev/null", 2);
3145 if (fd >= 0)
3146 {
3147 dup2 (fd, 0);
3148 dup2 (fd, 1);
3149 dup2 (fd, 2);
3150 }
3143 execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); 3151 execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
3144 _exit (-1); /* Can't exec /bin/mkdir */ 3152 _exit (-1); /* Can't exec /bin/mkdir */
3145 3153
3146 default: /* Parent process */ 3154 default: /* Parent process */
3147 while (cpid != wait (&status)); /* Wait for kid to finish */ 3155 wait_for_termination (cpid);
3148 } 3156 }
3149 3157
3150 if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) 3158 if (synch_process_death != 0 || synch_process_retcode != 0)
3151 { 3159 {
3152 errno = EIO; /* We don't know why, but */ 3160 errno = EIO; /* We don't know why, but */
3153 return -1; /* /bin/mkdir failed */ 3161 return -1; /* /bin/mkdir failed */
@@ -3162,7 +3170,7 @@ int
3162rmdir (dpath) 3170rmdir (dpath)
3163 char *dpath; 3171 char *dpath;
3164{ 3172{
3165 int cpid, status; 3173 int cpid, status, fd;
3166 struct stat statbuf; 3174 struct stat statbuf;
3167 3175
3168 if (stat (dpath, &statbuf) != 0) 3176 if (stat (dpath, &statbuf) != 0)
@@ -3171,24 +3179,32 @@ rmdir (dpath)
3171 return -1; 3179 return -1;
3172 } 3180 }
3173 3181
3182 synch_process_alive = 1;
3174 switch (cpid = fork ()) 3183 switch (cpid = fork ())
3175 { 3184 {
3176 3185
3177 case -1: /* Error in fork() */ 3186 case -1: /* Error in fork */
3178 return (-1); /* Errno is set already */ 3187 return (-1); /* Errno is set already */
3179 3188
3180 case 0: /* Child process */ 3189 case 0: /* Child process */
3190 fd = sys_open("/dev/null", 2);
3191 if (fd >= 0)
3192 {
3193 dup2 (fd, 0);
3194 dup2 (fd, 1);
3195 dup2 (fd, 2);
3196 }
3181 execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); 3197 execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
3182 _exit (-1); /* Can't exec /bin/mkdir */ 3198 _exit (-1); /* Can't exec /bin/mkdir */
3183 3199
3184 default: /* Parent process */ 3200 default: /* Parent process */
3185 while (cpid != wait (&status)); /* Wait for kid to finish */ 3201 wait_for_termination (cpid);
3186 } 3202 }
3187 3203
3188 if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) 3204 if (synch_process_death != 0 || synch_process_retcode != 0)
3189 { 3205 {
3190 errno = EIO; /* We don't know why, but */ 3206 errno = EIO; /* We don't know why, but */
3191 return -1; /* /bin/mkdir failed */ 3207 return -1; /* /bin/rmdir failed */
3192 } 3208 }
3193 3209
3194 return 0; 3210 return 0;