NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: FreeRADIUS instability



Can you try this: https://www.netbsd.org/~christos/res_kqueue.diff ?

christos

On Sep 29, 2021, at 6:12 PM, Pawel S. Veselov <pawel.veselov%gmail.com@localhost> wrote:

#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <fcntl.h>

int main(int argc, char ** argv) {

       struct addrinfo * res;

       getaddrinfo("www.netbsd.org", NULL, NULL, &res);

       pid_t pid = fork();
       if (pid < 0) {
               perror("fork");
               return 1;
       }

       if (!pid) {
               // child
               int fd = open("/etc/hosts", O_RDONLY);
               getaddrinfo("www.netbsd.com", NULL, NULL, &res);
               char buf[101];
               int rc;
               while (1) {
                       rc = read(fd, buf, 100);
                       if (rc < 0) { perror("read"); }
                       if (rc <= 0) { break; }
                       buf[rc] = 0;
                       fprintf(stdout, "%s", buf);
               }
               fprintf(stdout, "\n");
               return !rc ? 0 : 1;
       } else {
               int s;
               while (1) {
                       waitpid(pid, &s, 0);
                       if (!WIFEXITED(s)) {
                               fprintf(stdout, "not ready\n");
                               continue;
                       }
                       return WEXITSTATUS(s);
                       break;
               }
       }

}

Attachment: signature.asc
Description: Message signed with OpenPGP



Home | Main Index | Thread Index | Old Index