- int ret;
- send_loop(ns);
- kill(pid_send, SIGTERM);
- waitpid(pid_send, &ret, 0);
- kill(pid_fw, SIGTERM);
- waitpid(pid_fw, &ret, 0);
- return 0;
+ pid_t pid_req = fork();
+ if (pid_req == -1)
+ {
+ perror("fork() req");
+ return 3;
+ }
+ if (pid_req) // Padre (Entrada por teclado)
+ {
+ int ret;
+ send_loop(ns);
+ kill(pid_send, SIGTERM);
+ waitpid(pid_send, &ret, 0);
+ kill(pid_recv, SIGTERM);
+ waitpid(pid_recv, &ret, 0);
+ kill(pid_req, SIGTERM);
+ waitpid(pid_req, &ret, 0);
+ return 0;
+ }
+ else // Hijo 1 (Proceso de request DNS)
+ {
+ ns.req_loop();
+ return 0;
+ }