我想出了这样的事情..更改控制终端
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