Skip to content

Commit

Permalink
Desativa alarme quando existe comunicaçao no pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
80Hefner committed Jun 15, 2020
1 parent 10d8aff commit a974382
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion TP44/argus.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ int main(int argc, char const** argv)
// Send command to server
write(fd_fifo_client_server, buffer, strlen(buffer));
if (DEBUG_STATUS) printf("[DEBUG] wrote '%s' to fifo\n", buffer);
close(fd_fifo_client_server);

// Wait for server to finish command execution
pause();
Expand Down
12 changes: 8 additions & 4 deletions TP44/src/server_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int exec_chained_commands (char* commands)
}


// Launch a child that receives input from the previous command and sends it to the next, messuring inactivity time
// Launch a child that receives input from the previous command and sends it to the next, messuring pipe inactivity time
if (pipe(p[0]) != 0) {
perror("Pipe");
return -1;
Expand All @@ -246,8 +246,10 @@ int exec_chained_commands (char* commands)

size_t bytes_read;
char buffer[BUFFER_SIZE];
while ((bytes_read = read(p_inac[0][0], buffer, BUFFER_SIZE)) > 0)
while ((bytes_read = read(p_inac[0][0], buffer, BUFFER_SIZE)) > 0) {
alarm(0);
write(p[0][1], buffer, bytes_read);
}

close(p[0][1]);
close(p_inac[0][0]);
Expand Down Expand Up @@ -319,7 +321,7 @@ int exec_chained_commands (char* commands)
current_execution_pid = next_execution_pid;


// Launch a child that receives input from the previous command and sends it to the next, messuring inactivity time
// Launch a child that receives input from the previous command and sends it to the next, messuring pipe inactivity time
if (pipe(p[i]) != 0) {
perror("Pipe");
return -1;
Expand All @@ -340,8 +342,10 @@ int exec_chained_commands (char* commands)

size_t bytes_read;
char buffer[BUFFER_SIZE];
while ((bytes_read = read(p_inac[i][0], buffer, BUFFER_SIZE)) > 0)
while ((bytes_read = read(p_inac[i][0], buffer, BUFFER_SIZE)) > 0) {
alarm(0);
write(p[i][1], buffer, bytes_read);
}

close(p[i][1]);
close(p_inac[i][0]);
Expand Down

0 comments on commit a974382

Please sign in to comment.