-
-/* Remove directory DPATH.
- Return 0 if successful, -1 if not. */
-
-int
-rmdir (dpath)
- char *dpath;
-{
- int cpid, status;
- struct stat statbuf;
-
- if (stat (dpath, &statbuf) != 0)
- return -1; /* stat set errno. */
-
- if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
- {
- errno = ENOTDIR;
- return -1;
- }
-
- cpid = fork ();
- switch (cpid)
- {
- case -1: /* Cannot fork. */
- return -1; /* errno is set already. */
-
- case 0: /* Child process. */
- execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
- _exit (1);
-
- default: /* Parent process. */
- while (wait (&status) != cpid) /* Wait for kid to finish. */
- /* Do nothing. */ ;
-
- if (status & 0xFFFF)
- {
- errno = EIO; /* /bin/rmdir failed. */
- return -1;
- }
- return 0;
- }
-}