-
popen debug
we call popen function repeat, sometime it work well,sometime it is wrong. when it work well , we get the command line execute filename;
when it is wrong , we get the result "s_path_name[i]=(%o)" : (0) (0) (0) (0 ) (0). we get the result (114) (116) ...(12) (0) when it work well.
if you check the fp , you will find that "fp[0]=%ld" : (537303080) when it work well, (537303072) when it is wrong.
the c code below:
sprintf( s_command, "/usr/bin/ps -p %ld |/usr/bin/awk '$1 == %ld {print$4}'", pid, pid );
if( ( fp = popen( s_command, "r" ) ) == NULL )
{
return( FATAL );
}
fscanf( fp, "%s", s_path_name );
for ( i_count=0; i_count<=10; i_count++ )
fprintf( stderr, "(%ld)", fp[i_count] );
for ( i_count=0; i_count<=10; i_count++ )
fprintf( stderr, "(%o)", s_path_name[i_count] );
if ( pclose( fp ) == -1 )
fprintf( stderr, "\n the pclose error");
Last edited by clark_x; 08-31-2001 at 01:19 AM.
-