我想出了這樣的事情..更改控制終端
int main (unsigned argc, char **argv)
{
printf("***this is the original terminal window!!!***\n");
if(!fork()){//child
system("gnome-terminal -e ./client");
}
else{
printf("this is the parent, printing in the original terminal window\n");
}
}
它打開其中執行./client一個新的終端窗口。唯一的問題是在./client事情結束後新的終端窗口會自動關閉。如何在不使用./client上的for(;;)
做一些愚蠢的事情的情況下修復此問題?此外,這種方法整體小於最佳的解決方案......
我真的想什麼,能夠做的是:
int main (unsigned argc, char **argv)
{
printf("***this is a generator!!!***\n");
if(!fork()){//child
system("gnome-terminal or wathever"); //the solution must be here right??
printf("this get's printed on the new window and whatever i do on the\
child process get's done there too")
//and the window won't close automatically
}
else{
printf("this is the parent, printing in the original terminal window\n");
}
}
這將是更加靈活,我只是不喜歡不必exec()
從另一個文件...
我使用Ubuntu 11.10和語言是C
至於第一部分:你總是可以只放在客戶端(例如,'客戶端;讀取foo')之後暫停以保持終端打開。至於推出一個終端,並獲得其「pty」......我不知道。 – BRFennPocock 2011-12-22 19:59:42