Sponsored Content
Top Forums Shell Programming and Scripting will child processes be created when executing "ps"? Post 302506603 by sleepy_11 on Monday 21st of March 2011 11:10:32 AM
Old 03-21-2011
Question will child processes be created when executing "ps"?

Hi

I'm trying to write some code to confirm there is only one running instance in memory like below:
Code:
/usr/ucb/ps  -auxww | egrep -v 'grep |vi |tail |more |cat ' | egrep ${SCRIPT_NAME} |  egrep -v " \-h| \-help| \-v"

But sometimes i found there is some child processes are are created as below:
Code:
 0     0 28796 27072  0   0 20 1456 1376          R pts/7     0:00 /usr/bin/ksh ./myprogram.ksh
 0     0 28829 28796  0   0 20 1448    ?          R pts/7     0:00 /usr/bin/ksh ./myprogram.ksh
 0     0 28831 28796  0   0 20 1448    ?          R pts/7     0:00 /usr/bin/ksh ./myprogram.ksh

pid28796 is the program i launched, and the lower two are forked as child processes. the number of child process is 2-4.

I definitely sure that there is no "fork" in my script, as such issue is there even if i only keep this command in it. And ptree can never show the detail about it

does anyone know why there are multiple instances?

thanks in adv.

Last edited by Scott; 03-21-2011 at 12:17 PM.. Reason: Code tags, please...
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Programming

"No child processes" and waitpif

Hi everybody, i'm using a signal handler for the SIGCHLD signal. void InstallNewSigChldHandler() { struct sigaction act; struct sigaction oldAct; act.sa_handler = CallWaitChildProcess; sigemptyset(&act.sa_mask); act.sa_flags = SA_NOCLDSTOP; if... (5 Replies)
Discussion started by: Zipi
5 Replies

3. AIX

Aix5.3 "freeze" when mounting newly created fs

Hello, When I tried to mount /appli21 with smit, the terminal "freezed" (ssh connection still active but always showing the same window, no new telnel or ssh connection allowed) and I had to have the machine restarted to be able to connect again. my volum group datavg: VOLUME GROUP: datavg... (8 Replies)
Discussion started by: farmer
8 Replies

4. UNIX for Dummies Questions & Answers

Kill child processes, when parent is "bash"

Consider this simple command line bash -c 'echo $$ ; sleep 10000'This will print the newly created bash PID and sleep for a long time. If I go to another terminal and do something like ps -flax | grep leepI'll see something like 501 92418 91910 0 0:00.00 ttys000 0:00.00 bash -c echo $$... (5 Replies)
Discussion started by: teras
5 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Solaris

I attempt to know. Why has been created the "local"directory?

Hello guys. It is common knowledge that the directory /usr/openwin/lib contains standart “locale” directory which contains fonts for difference international locales. But I have found in /usr/openwin/lib one more directory with name «local». It contains the same iso_8859_1 directory with... (1 Reply)
Discussion started by: wolfgang
1 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Expect: spawn id exp5 not open while executing "expect "$" { send "sudo su -\r" }"

Hi All, i am trying to ssh to a remote machine and execute certain command to remote machine through script. i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as expect: spawn id exp5 not open while executing "expect "$" {... (3 Replies)
Discussion started by: Siddharth shivh
3 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
fork(2) 							System Calls Manual							   fork(2)

Name
       fork - create a new process

Syntax
       #include <sys/types.h>
       #include <unistd.h>

       pid = fork()
       pid_t pid;

Description
       The  system  call causes creation of a new process.  The new process (child process) is an exact copy of the calling process except for the
       following:

       o    The child process has a unique process ID.

       o    The child process has a different parent process ID (that is, the process ID of the parent process).

       o    The child process has its own copy of the parent's descriptors.  These descriptors reference the same underlying objects, so that, for
	    instance,  file  pointers  in file objects are shared between the child and the parent, so that a on a descriptor in the child process
	    can affect a subsequent read or write by the parent.  This descriptor copying is also used by the shell to	establish  standard  input
	    and output for newly created processes as well as to set up pipes.

       o    The child processes resource utilizations are set to 0.  For further information, see

Return Values
       Upon  successful  completion,  returns  a  value  of  0	to the child process and returns the process ID of the child process to the parent
       process.  Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set	to
       indicate the error.

Diagnostics
       The system call fails and no child process are created under the following conditions:

       [EAGAIN]       The system-imposed limit {PROC_MAX} on the total number of processes under execution would be exceeded.

       [EAGAIN]       The system-imposed limit {CHILD_MAX} on the total number of processes under execution by a single user would be exceeded.

       [ENOMEM]       There is insufficient swap space for the new process.

See Also
       execve(2), wait(2)

																	   fork(2)
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy