Commit 5b5248e7 authored by Taddeüs Kroes's avatar Taddeüs Kroes

- Some final changes to OS ass3.

parent cfbf4096
......@@ -103,7 +103,7 @@ static void gup(FILE * log1, FILE * log2, int pipe_id[2], int myNumber)
void
signal_handler(int signum)
{
char *sig = "TERM";
char * sig = "TERM";
pid_t pid;
switch( signum )
......@@ -129,8 +129,6 @@ signal_handler(int signum)
default:
puts("This handler is unapplicable for this type of signal");
}
errno = 0;
}
/*
......@@ -148,11 +146,7 @@ main(int argc, char * argv[])
/* Save parent process id for signal handler */
parent_pid = getpid();
/* Open one buffered and one unbuffered log */
printf("argc: %d\n", argc);
log1 = fopen("child.log1", "wt+");
log2 = fopen("child.log2", "wt+");
setvbuf(log2, NULL, _IONBF, BUFSIZ);
/* Create pipe, exit with error on failure */
if( pipe(pipe_id) )
......@@ -164,13 +158,18 @@ main(int argc, char * argv[])
/* Bind signal handlers */
if( sigaction(SIGINT, &action, NULL)
+ sigaction(SIGTERM, &action, NULL)
+ sigaction(SIGCHLD, &action, NULL) < 0 )
|| sigaction(SIGTERM, &action, NULL)
|| sigaction(SIGCHLD, &action, NULL) )
{
perror("An error occured while binding the signal handlers \n");
exit(1);
}
/* Open one buffered and one unbuffered log */
log1 = fopen("child.log1", "wt+");
log2 = fopen("child.log2", "wt+");
setvbuf(log2, NULL, _IONBF, BUFSIZ);
/* Keep reading input */
while( (c = getchar()) )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment