Sponsored Content
Top Forums Shell Programming and Scripting How to make the parent process to wait for the child process Post 302354994 by sennidurai on Monday 21st of September 2009 07:12:58 AM
Old 09-21-2009
i have use wait, wait $PID and then wait $!. but the process will not wait for the child process.
 

10 More Discussions You Might Find Interesting

1. Programming

parent and child process question?

Hi everybody, I'm trying to understand how a parent and child processes interact. This function( below) basically measures the fork time from the perspective of the parent only. what i would like to know is how to measure the time from the perspective of parent and child (ie: inserting... (0 Replies)
Discussion started by: tosa
0 Replies

2. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

3. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

4. 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

5. UNIX for Dummies Questions & Answers

Command to find parent and child process?

Hi, I have a script that calls other scripts/commands which may or may not spawn other process. From my understanding, when I do a ps -ef, the highest numbered process ID is supposed to be the parent ID of all the other related child processes, is this correct? In most or all... (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Emergency UNIX and Linux Support

signal between parent process and child process

Hello, everyone. Here's a program: pid_t pid = fork(); if (0 == pid) // child process { execvp ...; } I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process. However I don't want to child process to receive the... (7 Replies)
Discussion started by: jackliang
7 Replies

7. 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

8. Shell Programming and Scripting

parent process needs to wait

I have two scripts lets say A.expect and B.sh needs to be executed. I am executing B.sh from A.expect where B.sh has sleep command. My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits. but my A.expect should execute only after completing B.sh. Is... (3 Replies)
Discussion started by: priya@2012
3 Replies

9. 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

10. UNIX for Beginners Questions & Answers

Wait till any one child process finishes

Hi I am facing a problem in my ksh. My main script is calling 3 different child process in the background. I am using wait to finish all and then submit another 3 child processes. Now what i want is , whenever any one child process finishes ,i want to submit next one.so that parallel 3... (2 Replies)
Discussion started by: Sangu
2 Replies
waitid(2)							System Calls Manual							 waitid(2)

NAME
waitid - wait for child process to change state SYNOPSIS
DESCRIPTION
The function suspends the calling process until one of its children changes state. It records the current state of a child in the structure pointed to by infop. If a child process changed state prior to the call to returns immediately. The idtype and id arguments are used to specify which children will wait for. If idtype is will wait for the child with a process ID equal to (pid_t)pid. If idtypeis will wait for any child with a process group ID equal to (pid_t)pid. If idtypeis will wait for any children and id is ignored. The options argument is used to specify which state changes will wait for. It is formed by OR-ing together one or more of the following flags: Wait for processes that have exited. Status will be returned for any child that has stopped upon receipt of a signal. Status will be returned for any child that was stopped and has been continued. Return immediately if there are no children to wait for. Keep the process whose status is returned in infop in a waitable state. This will not affect the state of the process; the process may be waited for again after this call completes. The infop argument must point to a structure. If returns because a child process was found that satisfied the conditions indicated by the arguments idtype and options, then the structure pointed to by infop will be filled in by the system with the status of the process. The si_signo member will always be equal to RETURN VALUE
If returns due to the change of state of one of its children, 0 is returned. Otherwise, -1 is returned and is set to indicate the error. ERRORS
The function will fail if: [ECHILD] The calling process has no existing unwaited-for child processes. [EINTR] The function was interrupted due to the receipt of a signal by the calling process. [EINVAL] An invalid value was specified for options, or idtype and id specify an invalid set of processes. APPLICATION USAGE
Threads Considerations In a multi-threaded application, only the calling thread is suspended by will not return until all threads in the process have reached the desired state. For example, if the or options are specified, will not return until all threads in the process have terminated, stopped or continued respectively. SEE ALSO
exec(2), exit(2), wait(2), <sys/wait.h>. CHANGE HISTORY
First released in Issue 4, Version 2. waitid(2)
All times are GMT -4. The time now is 03:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy