minix/commands/simple/chroot.c
Ben Gras e07a62161a . verbose recovery of tcpd
. chroot shows exit status to parent
2006-03-15 14:39:20 +00:00

28 lines
383 B
C

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
int
main(int argc, char *argv[])
{
int status;
if(argc != 3) {
fprintf(stderr, "usage: %s <root> <command>\n", argv[0]);
return 1;
}
if(chroot(argv[1]) < 0) {
perror("chroot");
return 1;
}
status = system(argv[2]);
if(WIFEXITED(status))
return WEXITSTATUS(status);
return 1;
}