hello everybode.Got some sort of "problems" with this stuff;
well this is a program
int main()
{
int Pipe[2];
int origStdin, origStdout;
int childPID;
origStdin = dup(0);
origStdout = dup(1);
pipe(Pipe);
if( (childPID = fork()) < 0 )
{
perror( "Fork Error" );
exit(-1);
}
if( !childPID )
{
dup2( Pipe[0], 0 );
dup2( origStdout, 1 );
close( origStdout );
close( origStdin );
close( Pipe[0] );
close( Pipe[1] );
execlp( "/bin/sort", "sort", NULL );
perror("Execl error");
exit(-1);
}
dup2( Pipe[1], 1 );
close( Pipe[0] );
close( Pipe[1] );
close( origStdout );
close( origStdin );
execlp( "/bin/cat", "cat","a.txt","b.txt", NULL );
perror( "EXEC Error");
return 0;
}
problem is that :after the work hav done it[program] (unfortunatly top utility do not show nor cat nor sort) stuck(freezes or smth) )just got it whats that!
it tty or who? do not show its bash-blablabla-$ ? why? and how to make to show this string?