Sponsored Content
Full Discussion: PIDs of background process
Operating Systems HP-UX PIDs of background process Post 61817 by ramkumar on Wednesday 9th of February 2005 04:36:00 AM
Old 02-09-2005
PIDs of background process

How to track the pid of a background child process(shell script) from a parent script ?

For example :-

$ sleep 10000 &
[1] 4220

where 4220 is the pid of bg process sleep.

Now my requirement is to keep the sleep statement in a shell script(test.ksh) and will be invoking it from another shell script (test2.ksh).

Is there any way to get the pid of test.ksh (child background process) from test2.ksh?

Last edited by ramkumar; 02-09-2005 at 06:44 AM.. Reason: To make it more clear
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

2. Shell Programming and Scripting

cause a process to be in background

Hi My script - main.sh, execute program1.sh in background and program2.sh in foreground . program1.sh holds the process ID of program2. program1.sh after a while needs to move the process of program2.sh to background. How? (0 Replies)
Discussion started by: avnerht
0 Replies

3. Shell Programming and Scripting

background process

can anybody plz tell me how can i find the background processes running. (2 Replies)
Discussion started by: Raom
2 Replies

4. Shell Programming and Scripting

Help in background process

Hi, I have a main script(main.ksh) within which I have called another script(sub.ksh). The sub.ksh script is made to run in the background using '&'. The main.ksh script logs the information in a logfile main_ddmmyy and the sub.ksh script also logs the information in the log file sub_ddmmyy.... (5 Replies)
Discussion started by: chella
5 Replies

5. Shell Programming and Scripting

background process

i gave a copy process in the background( to copy around 100GB) , while in progress, the session got terminated. when i relogged in and checked the destination folder the copying was in progress... how could it happen(copying) when the shell terminates??? :rolleyes: (2 Replies)
Discussion started by: vinod.thayil
2 Replies

6. UNIX for Dummies Questions & Answers

Background Process

I need to submit a script that will continue to run after logging out and after a reboot or shutdown. I entered the following: nohup script & The script continues to run in the background after logging off the system but is killed after a reboot or shutdown. Any help would be greatly... (1 Reply)
Discussion started by: powwm
1 Replies

7. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

8. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

9. Shell Programming and Scripting

Capturing PIDs of same process at different instances

Hi, I'm gonna launch a process from my 'C' code. I'm gonna launch it a few times. I would like to capture the PID of that process each time I launch. I have to copy the each PIDs into a 'C' variable and I have to kill all of them when I exit from the 'C' code. My requirement is int... (3 Replies)
Discussion started by: suryaemlinux
3 Replies

10. Shell Programming and Scripting

Make background process interact with fg process

Hi, I have written a menu driven shell script in which as per the choice, I run the another script on background. For eg: 1. get info 2)process info 3)modify info All the operations have different scripts which i schedule in background using &. However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies
setpgid(2)							   System Calls 							setpgid(2)

NAME
setpgid - set process group ID SYNOPSIS
#include <sys/types.h> #include <unistd.h> int setpgid(pid_t pid, pid_t pgid); DESCRIPTION
The setpgid() function sets the process group ID of the process with ID pid to pgid. If pgid is equal to pid, the process becomes a process group leader. See intro(2) for more information on session leaders and process group leaders. If pgid is not equal to pid, the process becomes a member of an existing process group. If pid is equal to 0, the process ID of the calling process is used. If pgid is equal to 0, the process specified by pid becomes a process group leader. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The setpgid() function will fail if: EACCES The pid argument matches the process ID of a child process of the calling process and the child process has successfully executed one of the exec family of functions (see exec(2)). EINVAL The pgid argument is less than (pid_t) 0 or greater than or equal to PID_MAX, or the calling process has a controlling ter- minal that does not support job control. EPERM The process indicated by the pid argument is a session leader. EPERM The pid argument matches the process ID of a child process of the calling process and the child process is not in the same session as the calling process. EPERM The pgid argument does not match the process ID of the process indicated by the pid argument, and there is no process with a process group ID that matches pgid in the same session as the calling process. ESRCH The pid argument does not match the process ID of the calling process or of a child process of the calling process. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
intro(2), exec(2), exit(2), fork(2), getpid(2), getsid(2), attributes(5), standards(5) SunOS 5.10 28 Dec 1996 setpgid(2)
All times are GMT -4. The time now is 07:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy