tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* fork, tee and a defunct process
@ 2003-05-28 15:11 Eiler, James A.
  0 siblings, 0 replies; only message in thread
From: Eiler, James A. @ 2003-05-28 15:11 UTC (permalink / 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-28 15:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-28 15:11 fork, tee and a defunct process Eiler, James A.

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