01-30-2007
parent shell pid
hi folks
can any suggest me how to get a parent processid in the script if i am executing this in the script
vi myscript.sh
echo "parent shell pid"$$
sh myscript.sh
but when i am executing this i am getting a new pid(actually that is the child pid) whenever i am executing this script, so can any suggest how to get parent pid , which doesnt change any number of times i execute this script.
fine hoping for the answer
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a script that I want to run in my current shell. I know that if I start it with a period ie '. myprogram' that this will cause it to run in my current shell instead of starting a new shell for it. What if I forgot to put the period. Is there some command that I can put in 'myprogram'... (1 Reply)
Discussion started by: Alan Bird
1 Replies
2. Shell Programming and Scripting
I have always used the "$$" environment variable to find the current process number. Is there any similar way or perhaps something else to easily find the parent process number? I realize I could do something like ps and grep for the process and cut or awk out the parent process but I wanted to... (1 Reply)
Discussion started by: scotbuff
1 Replies
3. Shell Programming and Scripting
Hi,
I haev to devlop a script which when executed will take in a sudo privelege and run a set of commands then will go back to parent shell and execute the rest of the command
But the problem I am facing is that when the script is executed it takes the sudo privelege but it waits for the... (0 Replies)
Discussion started by: ruchirmayank
0 Replies
4. Shell Programming and Scripting
hi experts(novice people can stay away as it is no child's game),
i am developing a script which works like recycle bin of windows.
the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies
5. UNIX for Advanced & Expert Users
how can we give input to parent shell?
i mean shell that is creating a child and our c prograame will run on that child..and then it return to parent shell..
what i want to do i want execute a c programe that will give command as input to parent shell & get output from parent shell and... (1 Reply)
Discussion started by: gajju
1 Replies
6. Shell Programming and Scripting
Hi,
I am new this forum. I request you peoples help in understanding and finding some solution to my problem.
Here it goes:
I need to perform this set of actions by writing a shell script. I need to read a config file for the bunch of processes to execute.
I need to fecth the pid of... (4 Replies)
Discussion started by: sachin4sachi
4 Replies
7. UNIX for Advanced & Expert Users
Hi,
I am logging in from my PC terminal to a linux host using ssh. Is it possible to execute a command on the parent PC terminal from the linux host during login. NOte that the parent PC does not have sshd running.
Sam (1 Reply)
Discussion started by: sardare
1 Replies
8. Shell Programming and Scripting
hi all,
for an example:
$ ps -ef | grep apache | awk '{ print $2, $3 }'
24073 11784
28021 1
28022 1
28038 1
28041 28040
28045 28041
28047 28041
28040 1
28049 28041
28051 28041
28053 28041
28030 1
28054 28041
28055 28041
28056 28041
28057 28041 (5 Replies)
Discussion started by: raghur77
5 Replies
9. Shell Programming and Scripting
Hi, I am looking for a solution for the following problem:
Im Using tcpdump within a shellskript started in a subshell by using brackets: ( /usr/sbin/tcpdump -i ... -c 1 )
- I want the outout of tcpdump saved in a variable
- Than tcpdump-Process in the Subshell should be killed
- and I... (6 Replies)
Discussion started by: 2retti
6 Replies
10. Shell Programming and Scripting
Hi,
I am using this command fuser_result=`fuser -f /web/$1/admin-*/logs/access` to get the parent pid of the process.
However, The output differs and at times it shows two pids instead of one thus failing the logic of my script. See output below:
bash-3.2$ fuser -f... (3 Replies)
Discussion started by: mohtashims
3 Replies
LEARN ABOUT PHP
pcntl_fork
PCNTL_FORK(3) 1 PCNTL_FORK(3)
pcntl_fork - Forks the currently running process
SYNOPSIS
int pcntl_fork (void )
DESCRIPTION
The pcntl_fork(3) function creates a child process that differs from the parent process only in its PID and PPID. Please see your system's
fork(2) man page for specific details as to how fork works on your system.
RETURN VALUES
On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of
execution. On failure, a -1 will be returned in the parent's context, no child process will be created, and a PHP error is raised.
EXAMPLES
Example #1
pcntl_fork(3) example
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
pcntl_wait($status); //Protect against Zombie children
} else {
// we are the child
}
?>
SEE ALSO
pcntl_waitpid(3), pcntl_signal(3), setproctitle(3).
PHP Documentation Group PCNTL_FORK(3)