home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / mail / sendmail / 2980 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  3.6 KB

  1. Xref: sparky comp.mail.sendmail:2980 comp.sys.hp:14023
  2. Path: sparky!uunet!ornl!utkcs2!emory!wupost!usc!enterpoop.mit.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sun4nl!nikhefh!e07
  3. From: e07@nikhefh.nikhef.nl (Eric Wassenaar)
  4. Newsgroups: comp.mail.sendmail,comp.sys.hp
  5. Subject: Lost mail because of SIGTERM from window system
  6. Message-ID: <2117@nikhefh.nikhef.nl>
  7. Date: 13 Dec 92 15:56:18 GMT
  8. Organization: Nikhef-H, Amsterdam (the Netherlands).
  9. Lines: 77
  10.  
  11. Summary:
  12.     Some window systems send a SIGTERM signal to an entire
  13.     process group when a window is deleted. Some mail user
  14.     agents do not wait() for the sendmail child to exit.
  15.     This causes mail to be lost, and leftover garbage queue
  16.     files. To be more robust, sendmail should establish its
  17.     own process group.
  18.  
  19. Problem description:
  20.     If one uses the HP-VUE mailtool window (with elm as user
  21.     agent) under HP-UX 8.07 on a HP700 series machine to send
  22.     mail, the mail may not be delivered, and garbage df*, qf*,
  23.     or tf* files may be left in /usr/spool/mqueue.
  24.  
  25. Repeat-By:
  26.     Pop up a mailtool window, send some mail, and when elm
  27.     says "Mail sent!" delete the window.
  28.  
  29. Analysis:
  30.     The HP-VUE mailtool uses a probably old version of elm
  31.     as the user agent. If you click the window, use elm to
  32.     compose and send the mail, the mail is handed over to
  33.     sendmail, but elm does not wait for the forked sendmail
  34.     process to terminate. Immediately elm says "Mail sent!".
  35.     If you then drop the window, a SIGTERM signal is sent to
  36.     the process group, which includes the sendmail process
  37.     still busy building the queue files before delivery is
  38.     being attempted. sendmail catches the signal, removes
  39.     the lf* and xf* files, leaves everything else (in a still
  40.     undefined state), and quits.
  41.  
  42.     (It could be that elm really wants to wait() for sendmail,
  43.     but uses 'wait3(&st, WNOHANG, (struct rusage *)&rusage)'
  44.     which fails with EINVAL under HP-UX. However, this seems
  45.     unlikely. Probably elm does not wait() at all).
  46.  
  47. Fix:
  48.     The following workaround is possible: let sendmail establish
  49.     its own process group, by inserting the following code
  50.  
  51.         (void) setpgrp(0, getpid());
  52.  
  53.     at the point where it has figured out that it has to send
  54.     mail, i.e. in main.c before the code fragment
  55.         initsys();
  56.         setsender(from);
  57.  
  58. Comments:
  59.     I see no harm in making this a standard sendmail behaviour.
  60.     There are other mail user agents which do not wait() either.
  61.     sendmail thus protects itself against such mailers and
  62.     hostile window systems, and becomes more robust.
  63.  
  64.     I do believe that mailers should wait(). Usually, sendmail
  65.     is configured such that after the setup phase of accepting
  66.     the message, constructing the headers, and building the queue
  67.     files, it forks again to perform the actual delivery.
  68.     By wait()ing for the completion of the initial sendmail child,
  69.     the user agent can be sure that the setup phase is finished.
  70.  
  71.     When sendmail forks for delivery, the subchild disconnects,
  72.     but remains part of the process group. A SIGTERM to this
  73.     subchild would also be highly undesirable, but would not be
  74.     destructive, since the df* and qf* files are properly set up,
  75.     and delivery would be resumed during the next queue run.
  76.     Establishing a separate process group in the initial sendmail
  77.     child also protects the subchild against unwanted signals.
  78.  
  79.     On HP-UX, if you don't link with -lBSD, and on other XPG3 based
  80.     platforms, you need to use setpgid() instead of setpgrp().
  81.  
  82. Eric Wassenaar
  83. -- 
  84. Organization: NIKHEF-H, National Institute for Nuclear and High-Energy Physics
  85. Address: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
  86. Phone: +31 20 592 5012, Home: +31 20 6909449, Telefax: +31 20 592 5155
  87. Internet: e07@nikhef.nl
  88.