PPID differs in script and prompt


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users PPID differs in script and prompt
# 1  
Old 07-22-2010
PPID differs in script and prompt

I tried several times to get answer to the below problem. Someone can please help me?

Code:
[tmp]$ cat p1.sh
#!/bin/sh

`./c1.sh &`

while [ 10 -le 11 ]  # indefinite loop
do
       x=5;
done

[tmp]$ cat c1.sh [/B] # sleep for 10 sec and exit
#!/bin/sh
sleep 10;

Execute P1 as ./p1 &

Code:
[ tmp]$ ps -eaf | grep c1
pp1   20487     1  0 22:37 pts/14   00:00:00 /bin/sh ./c1.sh

[ tmp]$ ps -eaf | grep p1
pp1   20485 19920  6 22:37 pts/14   00:00:00 /bin/sh ./p1.sh

(1) Why does the PPID of c1.sh has been assigned to 1? Why can't it be PID of p1.sh? Thanks in advance

Last edited by pludi; 07-22-2010 at 09:51 AM.. Reason: code tags, please...
# 2  
Old 07-22-2010
Because the parent script did not wait for the child, the init process "adopted" it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output of echo $$ differs in Script than console

Hi All, I have a very basic query for 'echo $$' command. When I am executing echo $$ on console then it is giving different output than the execution of echo $$ in a script. Console Output: ------------------------- bash-3.2$ echo $$ 15610 bash-3.2$ In Script:... (3 Replies)
Discussion started by: manishdivs
3 Replies

2. UNIX for Dummies Questions & Answers

Process Name from PPID

Hi, I am currently trying to pin down a process NAME (could be a cron job or a tty) in Solaris. First I obtained a pid and then a ppid. I want to take the PPID and from there find the program/process that is making the VSH go high (cpu usage). I am currently trying to go up the chain using PS... (2 Replies)
Discussion started by: troystevens
2 Replies

3. Shell Programming and Scripting

Shall I go for uid or ppid?

Hi Guys, I'd like to ask your advice on the following, I've written this script to terminate a given process by name: #!/bin/bash echo 'Please enter the process you wish to terminate' read process pid=$(pidof $process) kill -9 $pid echo $2 to make it safer I want it to reject the... (4 Replies)
Discussion started by: Lora Graham
4 Replies

4. Shell Programming and Scripting

script execution differs in cron

I have the following script (MyScript): #!/bin/sh ps U erv | grep -v grep | grep -F "/usr/bin/collect -o 101" echo "Result: $?" When executed from the command line, I get ... (the line containing /usr/bin/collect -o 101) Result: 0 (which is correct since collect is running) When I... (4 Replies)
Discussion started by: lost_neko
4 Replies

5. Solaris

why process PPID changes to 1

Hi All, I have just started using SUN Solaris o.s version is :SunOS spdwa013(my server name) 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-480R My problem is that i have some processes running on that server they have a PID and a PPID. But sometimes the PPID for a particular process... (2 Replies)
Discussion started by: usha rao
2 Replies

6. Shell Programming and Scripting

how ./example.sh differs from . /example.sh and ./ example.sh

May i know the difference between the execution of the commands: ./example.sh . /example.sh and ./ example.sh the last and last but one is having space in between that is the difference please suggest me the answer for this...:confused: (4 Replies)
Discussion started by: lokeshpashine
4 Replies

7. UNIX for Dummies Questions & Answers

what is the meaning of ppid 1?

Is there any meaning on parent process id when it is equal = 1? It is found that most of the ppid is lower than pid of the same process by 1 when perform ps -ef but notice that some process's ppid is 1 (2 Replies)
Discussion started by: darkrainbow
2 Replies

8. UNIX for Advanced & Expert Users

pid differs

I always find that the pid I get from: /var/run/syslog-ng.pid and ps -ef |grep syslog-ng are different. this also happens on other pids. why? If I am going to kill a process, which pid should I use? (1 Reply)
Discussion started by: fredao
1 Replies

9. Shell Programming and Scripting

print the first 5 lines in which 2 files differs

it is a simple problem, but I am totally new to shell programming There are 2 files. I have to print the 5 five lines which are different. I appreciate any help. 10x. (2 Replies)
Discussion started by: atticus
2 Replies

10. Shell Programming and Scripting

Need a script to kill processes with PPID of 1

Hi, I have been trying to come up with a script to run as a cron job to kill any processes that have PPID of 1. I have created a file that contains the PID and the PPID. How can I read this file and then execute a kill on any PID where PPID is 1. The file looks like this: 4904 1 4455 1... (5 Replies)
Discussion started by: lbaysdon
5 Replies
Login or Register to Ask a Question