1/* rmdir.c
2   Remove a directory on a system which doesn't have the rmdir system
3   call.  This is only called by uupick, which is not setuid, so we
4   don't have to worry about the problems of invoking the setuid
5   /bin/rmdir program.  */
6
7#include "uucp.h"
8
9#include "sysdep.h"
10
11#include <errno.h>
12
13int
14rmdir (zdir)
15     const char *zdir;
16{
17  const char *azargs[3];
18  int aidescs[3];
19  pid_t ipid;
20
21  azargs[0] = RMDIR_PROGRAM;
22  azargs[1] = zdir;
23  azargs[2] = NULL;
24  aidescs[0] = SPAWN_NULL;
25  aidescs[1] = SPAWN_NULL;
26  aidescs[2] = SPAWN_NULL;
27
28  ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
29		   TRUE, TRUE, (const char *) NULL,
30		   (const char *) NULL, (const char *) NULL);
31
32  if (ipid < 0)
33    return -1;
34
35  if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
36    {
37      /* Make up an errno value.  */
38      errno = EBUSY;
39      return -1;
40    }
41
42  return 0;
43}
44