Qmail
[Top] [All Lists]

Re: tcpserver+recordio logging issue

To: qmail@list.cr.yp.to
Subject: Re: tcpserver+recordio logging issue
From: "Matthew R. Dempsky" <mrd@alkemio.org>
Date: Tue, 28 Nov 2006 08:59:26 -0600
Delivered-to: sp-com-lists@consult.net
Delivered-to: gmail-qmail@securepoint.com
Delivered-to: sp.com.list@gmail.com
Delivered-to: mailing list qmail@list.cr.yp.to
In-reply-to: <49002b820611280512j344e63d7i57d9339faf778a11@mail.gmail.com>
Mail-followup-to: qmail@list.cr.yp.to
Mailing-list: contact qmail-help@list.cr.yp.to; run by ezmlm
References: <49002b820611280512j344e63d7i57d9339faf778a11@mail.gmail.com>
On Tue, Nov 28, 2006 at 09:12:00PM +0800, d tbsky wrote:
> but somtimes that message is not the last. like this:
> tcpserver: end 5165 status 256
> tcpserver: status: 5/40
> 5165 > 220 xxxxxxxxxxxxxxxx
> 5165 > [EOF]

Process 5165 wrote to stdout, exited, and was reaped by tcpserver
before recordio received a time slice.

> anyway i can make it  allways the last message?

You need to ensure that recordio exits before tcpserver's child
process exits.  Below is a quick blahwait program I threw together as
proof of concept; it forks and runs the passed program, waits for it
to return, then waits for one more process to exit (hopefully,
recordio) before returning itself.

You can then replace ``recordio foo...'' with ``recordio blahwait
foo...''.  (Patching recordio or writing your own replacement would
probably be more robust.)

#include <unistd.h>
#include <sys/wait.h>

int main(int argc,char *argv[])
{
  pid_t pid;
  int status;
  switch (pid = fork()) {
    case -1: return 111;
    case 0: execvp(argv[1],argv + 1); return 111;
  }
  close(0);
  close(1);
  waitpid(pid,&status,0);
  wait(0);
  if (!WIFEXITED(status)) return 111;
  return WEXITSTATUS(status);
}

<Prev in Thread] Current Thread [Next in Thread>