#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <sys/time.h>

void showtime() {
	int pid;
	time_t time1;
	struct tm tm;
	char timestr[100];

	pid = getpid();
	time(&time1);
	//localtime_r(&time1, &tm);
	//strftime(timestr, sizeof timestr, "%Y/%m/%d %H:%M:%S", &tm);
	strftime(timestr, sizeof timestr, "%Y/%m/%d %H:%M:%S", localtime(&time1));
	printf("Process %d gets time %s\n", pid, timestr);
}

int main() {
	showtime();

	fork();

	if (chroot("/home/matt/test/jail") < 0) {
		perror("chroot");
		return 1;
	}

	fork();

	sleep(2);

	showtime();

	return 0;
}
