About forking and NSS:

How best does one use NSS to do create an app that accepts connection
requests and forking off children to handle them? That is, how best to do
the following but with NSS:

/*
   * Loop forever accepting connection requests and forking off
   * children to handle them.
   */
  while (1) {
   addrlen = sizeof(his_addr);
   fd2 = accept(ctl_sock, (struct sockaddr *)&his_addr, &addrlen);
   if (fork() == 0) {
    /* child */
    (void) dup2(fd2, 0);
    (void) dup2(fd2, 1);
    close(ctl_sock);
    break;
   }
   close(fd2);
  }

I don't see the equivalent to dup2 in NSS,  no way to duplicate an NSPR file
descriptor... Another solution could be to import the new fd2 into NSPR/NSS:
I thought that at one time NSS had a function for import an exiting FD into
NSPR. Is it gone?

-- POC



Reply via email to