Parent/child choice in sslio

Charlie Brady <[email protected]>
Newsgroups gmane.comp.misc.pape.general
Message-ID <Pine.LNX.4.44.0405131346010.26798-100000@e-smith.charlieb.ott.istop.com>
I've made use of sslio to add TLS support to Bruce Guenter's mailfront 
(see the bgware list for details). But I found debugging quite confusion 
because of the decision that sslio makes about the allocation of tasks to 
the parent and child after it forks.

I had modified smtpfront-qmail so that it would accept and acknowledge a 
"STARTTLS" command, then exec "sslio ... smtpfront-qmail".

What confused me was than I had an smtpfront-qmail process (pid N) before 
I gave the STARTTLS command, then had an smtpfront-qmail process (pid N) 
and child sslio process (pid N+1) after. It took a bit of head scratching 
to realise that process N was smtpfront-qmail, then sslio, then 
smtpfront-qmail again.

This patch would have avoided the confusion:

--- sslio.c.orig	Thu May 13 13:46:54 2004
+++ sslio.c	Thu May 13 13:47:38 2004
@@ -286,7 +286,7 @@
   if (pipe(encpipe) == -1) fatal("unable to create pipe for encoding");
   if (pipe(decpipe) == -1) fatal("unable to create pipe for decoding");
   if ((pid =fork()) == -1) fatal("unable to fork");
-  if (pid == 0) {
+  if (pid) {
     if (close(encpipe[1]) == -1)
       fatal("unable to close encoding pipe output");
     if (close(decpipe[0]) == -1)

I realise that you might want to wait for the child to terminate, and pass 
its status back as exit status of sslio, but I don't need that now.

---
Charlie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.