我有一个进程(读写终端类型),已经由后台进程执行。我可以用ps看到它。 试图将其带到前台,这是我尝试:将进程带到前台
int main()
{
FILE* fd = popen("pidof my_program","r");
// ...
// Some code to get the pid of my_program as mpid
//...
printf("pid of my_program is %d",mpid);
signal(SIGTTOU, SIG_IGN);
setpgid(mpid,0); // Set program group id to pid of process
tcsetpgrp(0,mpid); // Give it terminal stdin access
tcsetpgrp(1,mpid); // Give it terminal stdout access
return 0;
}
它不工作,虽然。有人可以帮助我吗? 谢谢。
但我在嵌入式Linux机器上运行,我只有busybox二进制文件,我没有fg,bg或可用的作业。我该怎么做呢? – Bornfree 2012-03-12 07:04:29
我可以编译上面的代码,就完成了。 – vulkanino 2012-03-13 08:24:31