tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: "Eiler, James A." <James.Eiler@alcoa.com>
Subject: fork, tee and a defunct process
Date: Wed, 28 May 2003 11:11:03 -0400	[thread overview]
Message-ID: <E29426A79658E247819F2B639A4CC93C04B58021@noaadc-mxu06.noa.alcoa.com> (raw)

Hi all,

I don't believe this is solely a Tru64 problem, but any insight would be
appreciated!

I've got a C program that forks.  I run the program from a shell script and
pipe the output to a log file.  A simplified version of the C code (hello.c)
is as follows:

#include <stdio.h>
#include <unistd.h>

main( )
{
   if( fork( ) == 0 ) {
      printf( "Entering child's code\n" );
      fflush( stdout );

      while( 1 ) {
         printf( "This is a test!\n" );
         fflush( stdout );
         sleep( 5 );
      }
   }
   else {
      printf( "Parent exiting, PID = %d\n", getpid( ) );
      exit( 0 );
   }
}

The command I'm issuing to get this running is:

# hello | tee hello.log& 

Stuff gets logged into the log file as expected, but an unexpected "side
effect" is a defunct process:

# ps -ef | grep defunct
eilerja   34718  34734  0.0 -        pts/2        0:00.00 <defunct>

When I look for the parent process, it looks like it's tee:

# ps -ef | grep 34734
eilerja   34718  34734  0.0 -        pts/2        0:00.00 <defunct>
eilerja   34734  32901  0.0 11:05:48 pts/2        0:00.00 tee hello.log

Any suggestions on how to eliminate the defunct process?

THANKS!

Jim


                 reply	other threads:[~2003-05-28 15:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox