Opening a new terminal window in C

前端 未结 3 611
忘掉有多难
忘掉有多难 2021-01-21 00:06

If I have a C program that I compile successfully and generate an executable, how do I instruct the program to open a new terminal window when I run it from the command line in

3条回答
  •  粉色の甜心
    2021-01-21 00:30

    You have to execute the terminal emulator. In my case (I have Kubuntu) it's Konsole, so it would be system("konsole").

    If I wanted it to execute ls on the current working directory, it'd be:

    system("konsole --hold -e ls .");
    

    What you can't do with system is control the spawned terminal. On the other side, if you use fork+exec, maybe you can interact with it by redirecting its streams (dup2)

提交回复
热议问题