Skip to content

Commit

Permalink
subo taller 1 resuelto
Browse files Browse the repository at this point in the history
  • Loading branch information
tomip01 authored Mar 28, 2023
1 parent 447d35d commit b6e00c9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
Binary file added taller-1/Enunciado.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions taller-1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CC=gcc

ARCH := $(shell uname -m)

BINS=hai

OBJS=$(BINS:=.o)

all: $(BINS)

# Dependencias
hai.o: hai.c

clean:
rm -rf $(OBJS) $(BINS)
46 changes: 46 additions & 0 deletions taller-1/hai.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <signal.h> /* constantes como SIGINT*/
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/reg.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int iteraciones = 0;

void sigurg_handler(int sig) {
printf("ya va!\n");
iteraciones++;
}

void sigint_handler(int sig) {
wait(NULL);
exit(EXIT_SUCCESS);
}

int main(int argc, char* argv[]) {
pid_t pid_hijo = fork();

if (pid_hijo == 0) {
signal(SIGURG, sigurg_handler);

while (iteraciones < 5) {}

pid_t padre = getppid();
kill(padre, SIGINT);
execvp(argv[1], argv+1);

} else {

signal(SIGINT, sigint_handler);

while (1) {
kill(pid_hijo, SIGURG);
sleep(1);
printf("sup!\n");
}
}

return 0;
}
Binary file added taller-1/hai64
Binary file not shown.

0 comments on commit b6e00c9

Please sign in to comment.