C forkpty problem
helo...
i am currently doing a simple program... i want to delete file using the interactive mode without the user inputing the answer through the keyboard... im using C as my programming language...
my program:
main()
{
int fds; //file descriptor
char cSlaveName;
pid_t pid;
if(pid = forkpty(&fds, cSlaveName, NULL, NULL) == 0)
{
execl("/bin/rm", "rm", "-i", "filetobedeleted", NULL);
return 2;
}
else
{
write(fds, "yes", 3);
}
}
as i have understand, the forkpty forks a process, also the filedescriptor takes the stdin, stdout and stderr, however, my write command cannot seems to be recognized by the stdin...
however, i tried reading the out and error... it seems to be working correctly... the writing to the in seems to be a problem...
i hope someone could help me out with my problem
|