ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Its my first question and mail on this forum .
Actually i m developing an application in which , when application runs , it forks 4 childs, i want to display a new terminal for each child process and execute a program using execl(), pleas tell me how can i execute a terminal(bash) from my application
I'm not exactly sure what you're trying to do here. If you want to just start bash from a program than you can use one of the exec() family of functions to run /bin/bash.
However, if you're trying to open a new terminal window under X then you'd use one of the exec() family of functions to call your terminal application (i.e. xterm, konsole, etc.)
If you just want to run 4 different commands then opening a new shell (bash) is quite unnecessary. But if you want to open 4 new terminal windows and then have 1 command run in each then you can use popen() to run xterm/konsole/whatever and then send your command to the pointer that popen() returned. Something like this:
Code:
int main(void)
{
FILE *term;
int i;
for(i = 0;i < 4;+=i)
{
term = popen("/usr/X11R6/bin/xterm", "w");
fprintf(term, "mycommand\n");
pclose(term);
}
}
I think that would work anyway. I don't have access to a linux box at the moment
If I didn't answer your question just leave some more detail on what you're trying to accomplish.
However, if you're trying to open a new terminal window under X then you'd use one of the exec() family of functions to call your terminal application (i.e. xterm, konsole, etc.)
Actually I am developing a router software
My application first detects all interfaces ( NICs ) attached to system and then starts a packet capturing engine for all interaces.
So that to run a packet capturing engine , i want to run each one in different x window terminal. I think now u can understand what i want
Hi ! Actually i have not worked much in Linux,
we have used linuc GUI , and developed our application in C .
Now i want to run each process in different trminal , bcaz when i runall processes in one terminal , time is not given to all processes concurretly ,and one can se that which process is executing at this time and all other processes running in that terminal remains idle, so thats why i want torun each process in different terminal ,
just tyell methat how can i execute a new terminal from y program and run a seperate process in it
thanks
Well, as I said, I wouldn't want a networking product to
depend on X.
The linux way would be to spawn a sub-process and
redirect its output to a FIFO, for instance, and then
your processes run concurrently, and you can check
their output by reading their FIFOs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.