02-26-2006
Run 4-processes concurrently
I need to run 4-processes concurrently in the background.
(I.e
![Embarrassment Smilie](https://www.unix.com/images/smilies/redface.gif)
ne parent with 4 concurrently running children.All 4 children should be in the same level.)
Parent
|
|
------- - - - - ----
| | | |
c1 c2 c3 c4 (same level)
I tried like this(code below)...But it doen't do what i want.Pls help me with this code. How can i
do this...
Is there any other easy way of doing this.....?
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#define NUM_CHILDREN 4
pid_t children[NUM_CHILDREN];
int i;
for(i=0;i<NUM_CHILDREN;i++){
if( (children[i]=fork()) == 0 ){
sleep(5);/**/
}
sleep(8);/**/
}
How can i verify that there are 4 concurrent processes running in the background?
(Is 'pstree' command OR any other better way! )
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
In a korn shell script, how can I run several processes in parallel at the same time?
For example, I have 3 processes say p1, p2, p3
if I call them as
p1.ksh
p2.ksh
p3.ksh
they will run after one process finishes. But I want to run them in parallel and want to display "Process p1... (3 Replies)
Discussion started by: sbasak
3 Replies
2. UNIX for Advanced & Expert Users
I am in a multi-user Linux environment at work. Other users easily run processes on my machine when my machine is idle, but when I try to use my machine, it is dead slow. The processes run by them always grab the top spot using 99% of my CPU time. Is there a way I can prevent others to run... (3 Replies)
Discussion started by: besharam
3 Replies
3. UNIX for Advanced & Expert Users
Hi,
My server runnning on SUN Solaris rel.5.5.1. I have been facing this issues for years. I have some Xbase databases running on the server. User is using emulation software to telnet to server for accessing application. If user logout application abnormally - by closing windows session, then... (2 Replies)
Discussion started by: lowtaiwah
2 Replies
4. UNIX for Advanced & Expert Users
Hi,
Would like to ask the experts if anyone knows how to run a script like this:
dtterm -title shell1
run process1 on shell1
dtterm -title shell2
run process2 on shell2
cheers!
p/s: sorry if i used the wrong forum, quite concussed after watching world cup for several nights; but I... (2 Replies)
Discussion started by: mochi
2 Replies
5. Programming
hi
i have a server socket programme which is running in HP/UX system and
then need to add a function about refreshing memory every miniute
because the socket programme is blocked , i have no idea about this
what should i do
thanks (10 Replies)
Discussion started by: benbenpig
10 Replies
6. Shell Programming and Scripting
how can I kill my processes which are run by hacker or another person who log in with my username and password (1 Reply)
Discussion started by: thsecmaniac
1 Replies
7. UNIX and Linux Applications
I would like to call a function called CIRCLE which is further beind called by other function but in a loop that CIRCLE fuction is being called. And this CIRCLE function starts another process which takes 3 hours to complete again, if i put that process in nohup &, I can go to the next command... (2 Replies)
Discussion started by: venugopalsmartb
2 Replies
8. UNIX for Dummies Questions & Answers
Hi all,
I have one script. Its job is to get 1 file from dirA and 1 file from dirB as parameters for another python script.
However, there are a lot of files in both dir A and B, so running this scripts really takes a lot of time. So I wonder if there are any ways that I can do this faster,... (6 Replies)
Discussion started by: yoyomano
6 Replies
9. UNIX for Dummies Questions & Answers
Is there any limit in UNIX that only a MAXIMUM no of processes can run at a time? If so, it exceeds then what would be the error we would receive? (4 Replies)
Discussion started by: jansat
4 Replies
10. Shell Programming and Scripting
Hello,
I need to run multiple shell processes simultaneously and output of the first process shall be the input of the second process but first process is never ending so both should be running in parallel. I do not wish to wait the end of the first process. I am under ubuntu 16.04.
... (3 Replies)
Discussion started by: baris35
3 Replies
LEARN ABOUT OSF1
xquerytree
XQueryTree(3X11) XQueryTree(3X11)
NAME
XQueryTree - query window tree information
SYNOPSIS
Status XQueryTree(display, w, root_return, parent_return, children_return, nchildren_return)
Display *display;
Window w;
Window *root_return;
Window *parent_return;
Window **children_return;
unsigned int *nchildren_return;
ARGUMENTS
Returns the list of children. Specifies the connection to the X server. Returns the number of children. Returns the parent window.
Returns the root window. Specifies the window whose list of children, root, parent, and number of children you want to obtain.
DESCRIPTION
The XQueryTree function returns the root ID, the parent window ID, a pointer to the list of children windows (NULL when there are no chil-
dren), and the number of children in the list for the specified window. The children are listed in current stacking order, from bottom-most
(first) to top-most (last). XQueryTree returns zero if it fails and nonzero if it succeeds. To free a non-NULL children list when it is no
longer needed, use XFree.
BUGS
This really should return a screen *, not a root window ID.
SEE ALSO
XFree(3X11), XGetWindowAttributes(3X11), XQueryPointer(3X11)
Xlib -- C Language X Interface
XQueryTree(3X11)