atividade2SO 2
atividade2SO 2
atividade2SO 2
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
int status;
if (fd_numbers == -1) {
exit(1);
if (fd_letters == -1) {
exit(1);
child_pid1 = fork();
if (child_pid1 == 0) {
exit(0);
exit(1);
}
child_pid2 = fork();
if (child_pid2 == 0) {
exit(0);
exit(1);
close(fd_numbers);
close(fd_letters);
int ch;
putchar(ch);
close(fd_numbers);
putchar(ch);
close(fd_letters);
return 0;
05 –
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
char command[100];
while (1) {
if (strcmp(command, "exit") == 0) {
printf("Saindo do programa.\n");
break;
if (child_pid < 0) {
exit(1);
} else if (child_pid == 0) {
exit(1);
} else {
int status;
if (WIFEXITED(status)) {
return 0;