#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#define REDIRECT_FILE "/home/ic/map.display"
int main()
{
printf("i am in parent") ;
int childPid ;
mkfifo( REDIRECT_FILE, S_IRUSR | S_IWUSR );
if( childPid= fork()==0)
{
close(0); close(1); close(2);
int file_desc = open( REDIRECT_FILE , O_WRONLY );
dup2( file_desc , 0);
dup2( file_desc , 1);
dup2( file_desc , 2);
printf("child output");
//char *const args[5] = { "xterm", "-e", "/bin/cat",
REDIRECT_FILE, NULL } ;
char *const args[6] = { "xterm", "-e", "tail", "-f",
REDIRECT_FILE , NULL } ;
execvp("xterm",args);
printf("child output");
sleep(1000) ;
close(file_desc);
}
sleep(1000);
return 0;
Here, the child process output should be displayed in another xtermQuote:}
window.
The above code only opens a window, but didn't output the things.
What am I doing wrong ?