1: /* $Header$ */ 2: 3: /* 4: * Author: Peter J. Nicklin 5: */ 6: 7: /* 8: * rm_dir() removes a directory named by dirname via the rmdir command. 9: * Returns exit status of rmdir command. 10: */ 11: #include <sys/param.h> 12: #include "bin.h" 13: #include "macro.h" 14: #include "system.h" 15: 16: rm_dir(dirname) 17: char *dirname; /* directory name */ 18: { 19: int pid; /* process identity */ 20: int status; /* child return status */ 21: int w; /* a child id */ 22: 23: if ((pid = FORK()) == 0) 24: { 25: execl(RMDIR, "rmdir", dirname, 0); 26: _exit(1); 27: } 28: while ((w = wait(&status)) != pid && w != -1) 29: continue; 30: status >>= NBBY; 31: status &= 0xff; 32: /* check if the directory exists because rmdir is unreliable */ 33: if (status == 0 && FILEXIST(dirname)) 34: { 35: warn("%s not removed", dirname); 36: status = 1; 37: } 38: return(status); 39: }