Linux:how to 'fork' not exec a new process in a new terminal window?

自闭症网瘾萝莉.ら 提交于 2019-12-12 06:27:57

问题


i am using fedora 15 with posix, and i want to fork my child processes in a new terminal window where i can interact only with the child process while the parent remain int he original terminal. I do not want to exec because that would require me to re arrange all of my code which doesnt seem fesaible at this moment as i have to present my project day after tomorrow.is it possible?how? i have tried forkpty but it gives me a compilation error.


回答1:


Have a look to man screen. I think it can be what you're looking for..

For example, you can run:

screen -dmS SESSION_NAME bash -c "COMMAND"

Where SESSION_NAME name is the name of the session, and COMMAND the command that you want to execute. In this way it will start as daemon, detached from your current shell. You're not obliged to do it, but it seems the solution that better fit your question. Remove -dmS SESSION_NAME if you want it in foreground.

Then, you can interact with the child with:

screen -r SESSION_NAME

You can come back to the main shell with:

screen -d


来源:https://stackoverflow.com/questions/11040334/linuxhow-to-fork-not-exec-a-new-process-in-a-new-terminal-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!