File: mkdir.c

package info (click to toggle)
ifmail 2.14tx8.10-32
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: ansic: 30,328; perl: 4,955; yacc: 839; makefile: 716; sh: 424; cpp: 235; lex: 206; awk: 24
file content (23 lines) | stat: -rw-r--r-- 448 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>

#define MKDIR "/bin/mkdir"
#define DEVNULL "/dev/null"

int mkdir(dir)
char *dir;
{
	int pid,rc,status;

	if ((pid=fork()) == 0)
	{
		freopen(DEVNULL,"w",stdout);
		freopen(DEVNULL,"w",stderr);
		rc=execl(MKDIR,MKDIR,dir,NULL);
		return rc;
	}
	while (((rc=wait(&status)) == pid) || (rc == 0));
	return ((status & 0xff) == 0) ? (status >> 8) : (status & 0xff);
}