Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to open new terminal through C program in linux
    primarykey
    data
    text
    <p>I have written client-sever code where I have many connections, let say each node represents different process on same machine. And to do that I have obviously use fork().</p> <p>But now problem is that all results get displayed on same terminal. I want to know is there any way such that after each <code>fork()</code> or process creation new terminal gets opened and all results get displayed for that process on particular terminal.</p> <p>P.S: I have tried <code>system("gnome-terminal")</code> but it just opens new terminal but all results get displayed again on same terminal only. All new terminals are just opens and remain blank without any result.</p> <p>Also I have gone through this link <a href="https://stackoverflow.com/questions/3445645/how-to-invoke-another-terminal-for-output-programmatically-in-c-in-linux">How to invoke another terminal for output programmatically in C in Linux</a> but I don't want to run my program with parameters or whatever. Its should be just like <code>./test</code></p> <p>Here is my code:-</p> <pre><code>for(int i=0;i&lt;node-1;i++) { n_number++; usleep(5000); child_pid[i]=fork(); if(!child_pid[i]) { system("gnome-terminal"); file_scan(); connection(); exit(0); } if(child_pid[i]&lt;0) printf("Error Process %d cannot be created",i); } for(int i=0;i&lt;node-1;i++) wait(&amp;status); </code></pre> <p>So basically what I want is for each process there should be new terminal displaying only that process information or result.</p> <p>What I exactly want:</p> <ul> <li>After fork() I have some data related to say process 1 then I want its output to one terminal</li> <li>Same goes with each process. So its like if I have 3 process then there must be 3 terminals and each must display process related data only. </li> </ul> <p>I know it can be doable using IPC(Inter Process Communication) but is there any other way around? I mean just 2-3 commands or so? Because I do not want to invest too much in coding this part.</p> <p>Thanks in advance!!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload