All pastes #126932 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-08-11 22:26 UTC
rendered paste body
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>


main (int argc, char *argv[]) {

	pid_t pid, sid; 
	timer_t timer;

	if (argc != 3) {
		printf ("Usage: %s %s \n", argv[0], "mp3 time");
	}

	pid = fork();	
	if (pid < 0 ) { exit(EXIT_FAILURE); } 
	else if (pid > 0) { exit(EXIT_SUCCESS); }

	umask(0);
	sid = setsid(); 
	if (sid < 0) { exit(EXIT_FAILURE); }
	
	if ((chdir("/")) < 0 )	{
		exit(EXIT_FAILURE);
	}

	close(STDIN_FILENO);
	close(STDOUT_FILENO);
	close(STDERR_FILENO);

	while(1) {
		/** Check for Time here **/
		timer=time(NULL);		
		printf("The current time is %s. \n", asctime(localtime(&timer)));
	}
}