- case -1: /* Cannot fork. */
- return -1; /* errno is already set. */
-
- case 0: /* Child process. */
- /* Cheap hack to set mode of new directory. Since this child
- process is going away anyway, we zap its umask.
- This won't suffice to set SUID, SGID, etc. on this
- directory, so the parent process calls chmod afterward. */
- status = umask (0); /* Get current umask. */
- umask (status | (0777 & ~dmode)); /* Set for mkdir. */
- execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
- _exit (1);
-
- default: /* Parent process. */
- /* Wait for kid to finish. */
- while (wait (&status) != cpid)
- /* Do nothing. */ ;
-
- if (status)
- {
- /* /bin/mkdir failed. */
- errno = EIO;
- return -1;
- }
- return chmod (dpath, dmode);