Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Wait till any one child process finishes Post 303037616 by Neo on Thursday 8th of August 2019 03:36:14 AM
Old 08-08-2019
It's a good idea to post your entire script if you want the best help you can get here at unix.com.

When you post your script, many people will review it and help you, for sure.

It's the best way forward, really Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

Howto spawn multiple child processes and wait?

As far as I can tell, the bash wait command waits for a logical "AND" of all the child processes. Assuming I am coding in C: (1) What is the function I would use to create multiple bash child process running perl? (2) What is the function I would use to reinvent the bash wait command so I... (4 Replies)
Discussion started by: siegfried
4 Replies

2. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

3. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

4. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

5. UNIX for Dummies Questions & Answers

Prints to screen when background process finishes

If I run "sleep 10&".. when that background process is done, is there a way for unix to print to screen to let me know? Thanks. (1 Reply)
Discussion started by: jmelai
1 Replies

6. Shell Programming and Scripting

Make cron wait for the child process

I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time. The code to find file and redirecting the output to text file is on a shell script /usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a... (4 Replies)
Discussion started by: nuthalapati
4 Replies

7. Programming

Parent,child wait,signal

Hello. I want to make a child do some stuff,wait,then the parent does some stuff and then child does some stuff and waits again.I have made the following but it does not work.Can anybody help me? pid1 = fork(); if (pid1 == -1) { perror("Can't create child\n"); ... (18 Replies)
Discussion started by: Cuervo
18 Replies

8. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

9. UNIX for Dummies Questions & Answers

How to wait for a grand child to finish?

Hello all, I have a very basic question. I have a requirement where in, I have a main process which forks a child process, which execs and runs a c executable corresponding to a daemon. In the c executable corresponding to a daemon, as everyone does, I fork another child process, and as part of... (7 Replies)
Discussion started by: sai2krishna
7 Replies

10. Shell Programming and Scripting

How make parent to wait from child process?

Hi all, I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens. could anyone please tell me how to make parent to wait in child process in shell script? thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies
waitid(2)							System Calls Manual							 waitid(2)

NAME
waitid - Wait for child process to change state SYNOPSIS
#include <sys/wait.h> int waitid( idtype_t idtype, id_t id, siginfo_t *infop, int options ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: waitid(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Identifies the type of process to be affected. Used with the id parameter, it suspends execution for the specified child process. Speci- fies either the process ID or process group ID of the child process. Used with the idtype parameter, it suspends execution for the speci- fied process. Specifies a pointer to a siginfo_t structure. Specifies the conditions that must occur before a wait operation is performed by the waitid() function. DESCRIPTION
The waitid() function holds a calling process until the state of a child process changes. The current state of the child is recorded in a structure pointed to by the infop parameter. If a child process changed state prior to the call to the waitid() function, the waitid() function returns immediately. The idtype and id parameters determine which child process the waitid() function is to act upon. If the idtype parameter is P_PID, the waitid() function waits for the child with a process ID equal to (pid_t)id. If the idtype parameter is P_PGID, the waitid() function waits for any child with a process group ID equal to (pid_t)id. If the idtype parameter is P_ALL, the waitid function waits for any child and the id parameter is ignored. The options parameter specifies the conditions that must occur before a wait operation is performed by the waitid() function. To specify a condition, use at least one of the following flags in a logical OR operation: Return the status for any child that was stopped and has been continued. Wait for processes to exit. Return immediately if no child processes in the requested state are present. Keep the child process whose status is returned in infop in a waitable state. Another wait for that child may occur with the same results. Wait for and return the process status of any child that has stopped upon receipt of a signal. [Tru64 UNIX] Wait for traced processes to become trapped or reach a breakpoint (see ptrace(2)). The infop parameter must point to a siginfo_t structure as defined in siginfo(5). This structure contains the status explaining why a process is in a wait state. The waitid() function returns if a child process is found that satisfies the conditions defined by the idtype and options parameters. In this case, the system fills in the structure pointed to by the infop parameter with the process status. The system always sets the si_signo structure member to SIGCHLD. RETURN VALUE
If the waitid() function returns because the state of a child process changes, it returns a value of zero (0). Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
The waitid() function sets errno to the specified values for the following conditions: The calling process has no unwaited-for child pro- cesses. [Tru64 UNIX] The infop parameter points to an invalid address. The waitid() function was interrupted due to the receipt of a signal by the calling process. An invalid value was used with the options parameter, or the idtype and id parameters specify an invalid set of processes. SEE ALSO
Functions: intro(2), exec(2), exit(2), fork(2), pause(3), ptrace(2), sigaction(2), signal(2), wait(2) Routines: pause(3) Files: siginfo(5) Standards: standards(5) waitid(2)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy