General :: Find All Child Processes Of A Parent Process Given To Script As Argument?

Feb 15, 2011

well i have just started with shell scripting...how to find all child processes of a parent process given to script as argument.

View 10 Replies


ADVERTISEMENT

General :: Child Processes Of A Parent Process Occupying Socket Memory?

Jul 22, 2010

I am facing an issue where the process starts hanging. When I closely look at the logs I come to know that some of the child processes that are forked by the parent process are not finished.

1) Is it possible that the child processes that are not finished occupy the socket memory of the parent process and ultimately a point is reached where no socket memory is available to fork new child processes.

2) What is the standard limit of socket memory in linux?

3) What is the fate of such child processes (as I have mentioned above)?

4) How to debug such cases so that the exact problematic area is identified?

View 2 Replies View Related

General :: Command To Find Parent And Child Process?

Apr 21, 2011

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 circumstances, I do a ps -ef | grep <processid> of my script and anything that spawns off that process IDs I assumed are the child processes of my script. If I want to terminate my script and all other child processes, then I kill the parent ID which is the highest numbered PID and this will subsequently kill all other child process IDs, is this correct?

Now, my question is whether there is any quick way of showing what are the child processes of a parent ID instead of what am currently doing now which is visually checking which one is the parent ID and "assuming" that the highest numbered PID is the parent ID of all the other processes. Below is a sample output of running ps -ef | grep exp | grep -v grep. I assume from the output below that the parent process/ID is PID 11322, is that correct?

Code:

oracle 11154 11153 0 21:20 ? 00:00:00 /bin/sh -c (. ~oracle/.profile; /bin/ksh /usr/local/oracle/scripts/expdp_o
oracle 11155 11154 0 21:20 ? 00:00:00 /bin/sh -c (. ~oracle/.profile; /bin/ksh /usr/local/oracle/scripts/expdp_o
oracle 11190 11155 0 21:20 ? 00:00:00 /bin/ksh /usr/local/oracle/scripts/expdp_schema.ksh dev01
oracle 11322 11190 0 21:20 ? 00:00:00 expdp

View 2 Replies View Related

General :: Sending Signal From Child Process To Parent Process?

Sep 8, 2010

Code:

#include <stdio.h>
#include <unistd.h>
#include <signal.h>

[code]....

Description of what the code does or what i intended to do:

1. Created a child process from parent process using 'fork()'

2. Sent a signal 'SIGALRM' from child process to parent process using 'sigqueue' function.

(The Third parameter of 'siqueue' function contains the message (message msg) which the child process wants to send to the parent process.'msg' is a stucture instance containing a) pid of child and b) string) 5. Print the 'msg' sent by child process inside the signal handler function 'sig_action_function' of the parent process I am getting some junk value when this line is executed

Code:

printf("%d
",msg->cpid);

I expected to get the pid of child process, which the child process sent to parent process through the signal.

View 3 Replies View Related

General :: Child Process That Dies And Has No Parent?

Dec 17, 2010

What happens to a child process that dies and has no parent process to wait for it and what's bad about this?

View 2 Replies View Related

Programming :: Ipc Between Parent And Child Processes Using Pipe?

Oct 13, 2010

If a process forks its child and communicate with the child using pipe, do closing the write end of the pipe and terminating the writing process have the same effect?

View 3 Replies View Related

General :: Killing Parent Process Without Killing Child Process (Linux C Programming)?

Mar 10, 2011

I want to kill parent process after "fork()" method. but if I kill parent process with "exit(0)" method, main() thread is terminated as well so child prosess doesn't work anymore. Is there any way to kill only parent process without affecting to child process?

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

[code]....

View 1 Replies View Related

SUSE :: Kill Child Process Without Killing The Parent?

Jun 21, 2010

I am trying to kill child process without killing the parent and seem to be having issues doing so. I have tried quite a few different commands and the end result is either killing all of them including the parent or not killing them at all.

View 1 Replies View Related

Programming :: Parent Process Block - Status Of Child

Mar 22, 2011

I am going to create a parent process and fork a child process from it. I want to write a code in such a way that whenever my child process end it must indicate that the child process is terminated by a signal or not. This code must be written in the parent process block.

View 6 Replies View Related

Programming :: Fork() - Variable Values Between Child And Parent Process?

Feb 24, 2010

Code:

int main()
{
int pi;
int i=10;
pid=fork();

[code]....

Q 1. The value of the variable pid returned by the fork() function will be greater than 0 in the parent process and equal to zero in the child process? but during forking, there values are exactly copied so what's went wrong here?

Q 2. "changes to the variable in one process is not reflected in the other process" why it is so? >> Even if we have variable i declared as a pointer or a global it wont make a difference.

Code:

int main()
{
int i, pid;
i=10;
printf("before fork i is %d

[code]....

Q. Through this program it is clear that both process is using the data from the same location, so where's the original value is residing when the child process is in execution.?

View 6 Replies View Related

Programming :: Splitting A Parent Process Into 2 Child And Then Merging Result?

Sep 15, 2010

What i am trying to do is i want to add numbers from 1 to 100. but that too using multiprocessing. So i made a c programme and using fork() command made two child processes. Now in one child process i am adding from 1 to 50. and in another i am adding 51 to 100. and then in the parent process adding the two results to get the final one. Now the result from the two function i am getting correctly. But after the wait() call the value returned is lost : See the programme below for reference

# include<stdio.h>
# include<unistd.h>
# include<sys/wait.h>
# include<stdlib.h>

[code].....

View 6 Replies View Related

Server :: Squid Parent: Child Process XXXXX Exited With Status 1?

May 24, 2010

I have a transparent proxy Squid-3.0 on Slackware 12.2. I used cron to restart squid every day at 7:30 AM (just /path.to.squid/squid -k kill && /path.to.squid/squid) Some days ago I saw in /var/log/messages that Squid was killed but haven't started. I started it manually and everything was OK. But today everything repeated. And the log file is interesting. I tried to find about it on http://squid-cache.org/ but al in vain. This is from /var/log/messages :

Code:

May 24 07:30:02 konura squid[17188]: Squid Parent: child process 17199 exited due to signal 9
May 24 07:30:02 konura squid[19038]: Squid Parent: child process 19040 started
May 24 07:30:03 konura squid[19038]: Squid Parent: child process 19040 exited with status 1
May 24 07:30:06 konura squid[19038]: Squid Parent: child process 19045 started

[code]....

I need to say that I haven't edited the config file for a long time, but this problem started to happen. ADDED, Solved: I'm not sure, but maybe I found the decision. I deleted about 400 mb of Sarg logs from /var partition. And now squid runs well. Besides, before deleting old logs, 'crontab -e' and 'pkgtool' didn't work And the system wrote me that it's no space left on device. At the same time, 'df -h' showed me that all partitions had enough free space. Seems strange, but that's it. After deleting old proxy statistics, generated by Sarg (this is about 400 mb) 1)squid runs OK and 2)there are no more that annoying messages about abscence of free space.

View 1 Replies View Related

General :: Find The Parent Process Of A Zombie Process?

May 4, 2010

How do you find the parent process of zombie processes?

When the child process is something where the parent is not entirely obvious...

Is there some way to list processes in tree format or something?

View 3 Replies View Related

Programming :: Find Number Of Child Processes (C / POSIX)?

May 26, 2010

I'm in the process of writing a program that is a server- it will accept connections and stuff, and spawn a child process for each. However, i've run into a small problem. I do NOT want to bother with keeping track of the processes unless i need to. So, i set SA_NOCLDWAIT (#ifdef) on a SIG_IGN to the SIGCHLD handler through sigaction interface. The standard says that it the kernel will then keep track of reaping zombie processes for me (a HUGE plus). However, upon receiving a SIGINT signal, i want to stop the server from accepting new connections (done), and then wait for there to be no new connections. I was thinking of just putting a loop like so:

Code:

while((wait(NULL) != (pid_t)-1) && errno != ECHILD);

However, I'm not *sure* that this will work, especially with SIGCHLD still ignored. So how can i tell if there are still child processes? I can't find any call like int getnumchld(pid_t proc); (i wish). Plus it would be inefficient to spin on that function anyway. OTOH, i would rather *NOT* have to do the same thing in a loop with a system("ps |...>file"); read(file); etc. either. Is there a way i can portably implement this feature (I was hoping i could run it on linux and the major BSDs, at least).

TO SUM IT UP:

How can i tell if a process has no child processes if i've SIG_IGN'd SA_NOCLDWAIT'd the SIGCHLD? Is there a _reasonably_ portable way to do so? I *don't* want to manually wait for EVERY process. Maybe only those still active at the time of SIGTERM, but that requires keeping track of the number of connections and whether those have terminated...

EDIT: Does anyone know if the above code *would* work, even with SIGCHLD ignored and the kernel cleaning up zombies *for* me? I checked the manpage and it doesn't say much.

EDIT1: Note that all of the processes are in the same process group and session. SO i can find them through this as well. Perhaps even setting the uid/gid and finding all processes run by that group?

EDIT2: i have an idea if the above isn't feasible. If there is no "elegant" way to do it, i could reduce the complexity by sending a SIGUSR1 to the whole process group. Each process would then set a flag telling it to send a SIGUSR1 in reply and send a SIGUSR2 when it is done executing. Then i could keep a count of signals. Maybe that would be *easier*. Or perhaps a count of all child processes and just a termination signal to decrement the counter.

View 2 Replies View Related

General :: Difference Between Child THREAD And Child PROCESS?

Jul 30, 2009

I am troubleshooting something and I got this problem.

If I do "pstree -p"

It shows,

Code:

[code]....

However, it does NOT show up in "ps -elf"

Code:

ps -elf | grep soffi
0 S whho 7734 1 0 80 0 - 36435 - 11:14 pts/2 00:00:03 /usr/lib/openoffice/program/soffice.bin -splash-pipe=5
0 S whho 7833 7759 0 80 0 - 751 - 11:21 pts/3 00:00:00 grep soffi

I was wondering if 7735, 7736, 7737, 7743 were really processes. Then I checked /proc, I could cd to /proc/7735, /proc/7736, etc, but I could not ls them out. I looked at the man page of "pstree", it says,

Code:

Child threads of a process are found under the parent process and are shown with the process name in curly braces, e.g.

icecast2---13*[{icecast2}]

So, what does all this mean? Does it mean that 7735, 7736, 7737, 7743 are just threads but not processes? If so, why could I cd to /proc/<id> but not see them in "ps -elf".

View 10 Replies View Related

Programming :: Under Which Circumstances A Child Process Creates Another Child Process Using Fork

Dec 7, 2009

Consider the following code:

Code:

int main()
{
int i=0;
pid_t pid;
for(i=0;i<2;i++)

[code]....

I get the following output:

Parent: chid_pid=4356 i=0 parent's pid=4355
This is child 4356 i=0
This is child 4357 i=1

[code]....

I can observe instead of two children(as I expect) processes there are three. This is because child process 4356 creates its own child. Why all the messages of the type "This is child X i=Y" are concentrated one under another? How exactly fork works? Is affected by the fact that I have a dual-core processor?

View 3 Replies View Related

General :: Cannot Inherit The Permission From Parent Folder To Child

Apr 26, 2011

I have setgid permission on my home directory (/home/XXXX) the permission look like below.

Code:

drwxrws--- 2 toshi jadu 4096 Apr 26 16:54 getset

If I create new directory in this getset folder the permission of getset folder could not inherit.

Code:

#cd getset
#mkdir test2
#ls |grep test2
drwxr-s--- 2 toshi jadu 4096 Apr 26 16:56 test2

As I know the setgid utility allow to inherit the permission from parent directory to child directory.

View 4 Replies View Related

General :: Finding All Attached Child Processes

Nov 17, 2010

I want to check all the child processes attached to a specific process. Say for a example; my process is a java process. Then I wanna know what are the processes attached to that java process. At the moment I use the command # ps aux|grep java; this gives the details about the currently running java process. So I can kill the whole java process using #kill -9 {pid} ...but there are sub processes attached (I guess child processes) to java process. I wanna view all of them & kill whatever the process I like not the whole thing. I'm using Red hat 5 enterprise edition. and currently a weblogic application server is running on that.

View 2 Replies View Related

General :: Memory Optimization For Child Processes?

Sep 6, 2010

I work on Linux for ARM processor for cable modem. There is a tool that I have written (as the job demands) that sends/storms customized UDP packets using raw sockets. I form the packet from scratch so that we have the flexibility to play with different options. This tool is mainly for stress testing routers.I actually have multiple interfaces created. Each interface will obtain IP addresses using DHCP. This is done in order to make the modem behave as virtual customer premises equipment (vcpe).

When the system comes up, I start those processes that are asked to. Every process that I start will continuously send packets. So process 0 will send packets using interface 0 and so on. Each of these processes that send packets would allow configuration (change in UDP parameters and other options at run time). Thats the reason I decide to have separate processes. I start these processes using fork and excec from the provisioning processes of the modem. The problem now is that each process takes up a lot of memory. Starting just 3 such processes, causes the system to crash and reboot.

I have tried the following:-

1-I have always assumed that pushing more code to the Shared Libraries will. when I tried moving many functions into shared library and keeping minimum code in the processes, it made no difference to my surprise.

2-I also removed all arrays and made them use the heap. However it made no difference. This maybe because the processes runs continuously and it makes no difference if it is stack or heap?

3-I suspect the process from I where I call the fork is huge and that is the reason for the processes that I make result being huge. I am not sure how else I could go about. say process A is huge -> I start process B by forking and excec. B inherits A's memory area. So now I do this -> A starts C which inturn starts B will also not help as C still inherits A?. I used vfork as an alternative which did not help either. I do wonder why.

View 1 Replies View Related

Programming :: Creates A Child Process With Fork And, When The Child Ends, Receives The SIGCHLD Signal And Wait For Its Termination?

May 23, 2011

I have a doubt about signals in C programming. I have done this little program to explain it. It creates a child process with fork and, when the child ends, receives the SIGCHLD signal and wait for its termination.Ok, quite easy, BUT when I execute this code the SIGCHLD signal is received twice, first as an error (returns -1) and the second one to finish the child process.I don't understand the meaning of the first received signal. Why is it generated? Is the code wrong? (if you add the SIGINT and press Ctrl+C during the execution it also receives two signals instead of one)

Code: #include <stdio.h>
#include <unistd.h>
#include <string.h>

[code]....

View 4 Replies View Related

Programming :: Get Child Pids From Parent Pid In Kernel Mode?

Jun 28, 2010

i need C code to get child pids from its parent pid in linux and in kernel mode, is there anything like getpid() or getppid() which works in kernel mode?

View 2 Replies View Related

Programming :: Perl Script (Both Parent And Child) Dieing

Apr 13, 2010

I am writing a perl script where forking a child and the child is waiting for some response from C++ exe. Here is the code snippet:

Code:
my $retPid = fork;
if ($retPid) {
# I am parent ...
# Install signal handler
$SIG{CHLD} = &REAPER; ...
# sleep for a week (6 hours at a time)
for ($cnt = 0; $cnt < 28 ; $cnt++) {
select(undef, undef, undef, 21600);
last if ( ! -e "/proc/$retPid" ); } ...
} else {
# I am child
($iid, $rc, %data) = $cpp_exe->getResponse(604800); # 1 week timeout ... }

If the cpp_exe takes very long time (around 30 hours) to respond then the perl script (both parent and child) is dieing. The SIG{CHLD} handler defined in parent is not getting called. It seems parent is dieing first then child is dieing (or may be both dieing at the same time). Why the script is dieing?

View 1 Replies View Related

Programming :: Why Does A Child Exit When The Parent Receives A Signal

Mar 16, 2011

I have a problem with the last point of some homework I have for an OS class. I need the program to print the pid upon execution, then for 10 seconds react to SIGUSR1, SIGUSR2 and SIGTERM. If either USR1 or USR2 is received, the 10 seconds are reset. Some of the functions I'm told to use are alarm(), pause() and signal(). The nicest way I found was to handle SIGUSR1, SIGUSR2 and SIGALRM in the parent process, with SIGALRM killing the child (with a SIGTERM). In the child a pause() (or for(; pause() would be enough for it to be alive until killed from the SIGALRM handler in the parent.

What I found is that I can't just do a wait() in the parent process, waiting for the child to be killed, since whenever the parent receives a SIGUSR1 or SIGUSR2, the right handler is called but the child exits nicely. I tried blocking/ignoring those signals in the child, since the default behaviour for SIGUSR1 and SIGUSR2 is to terminate the process, but the result is the same. The only way I could do it is using a waitpid() within a do { } while(!WIFSIGNALED(status)) since when the child gets killed with the parent's kill(), it's WIFSIGNALED, whereas when it exits after the parent handles a SIGUSR1/2, it's WIFEXITED.

P.S. What I'm doing to achieve the expected 10s window is calling alarm(10) in the parent process and again within the SIGUSR1/2 handlers. In the SIGALRM handler I kill the child and within the child I simply do a for(; pause()

View 4 Replies View Related

Software :: Nested Shell - Disown Job Not Found (Parent Or Child)

Jun 1, 2011

I'm in a nested shell trying to use disown to re-root myself as well as a child. Looks like this:

Code:
# echo $$
1234
# disown 1234
disown: job not found: 1234
# disown $$
disown: job not found: 1234
# pgrep mychild
2222
# disown 2222
disown: job not found: 2222

This is in zsh. The goal is to have process 1 (the root of all processes) to become the parent.

View 3 Replies View Related

General :: Get Parent PID Of A Given Process In GNU From Command Line?

Jun 8, 2010

Resolved before asked: cat /proc/1111/status | grep PPid

View 2 Replies View Related

General :: Fork() Always Return 0 Even In The Parent Process?

Mar 18, 2011

my code is very simple:

int pid, status;
printf("parent process id=%d, to call fork
",getpid());
if(pid=fork()<0)

[Code].....

but everytime I can only get two fork return pid=0. In parent process, the pid returned by fork() should be >0 and equal to the child process id.

View 1 Replies View Related

Programming :: Select() Call Does Not Detect Data In Pipe Between Parent And Child Program

Sep 23, 2009

i wanted to capture the stdout and stdin of a child process within a parent so that any output of child is sent to the parent and any input taken from the parent. code is simple enough and i have followed all code guidlines on the internet (some guidlines do differ also) my select call either hangs if i do not give a tmeout and with a timeout it returns 0 descriptors to be written to or read from:

below is the simple code for parent:

int main(void)
{
int outfd[2];
int infd[2];

[code].....

why select hangs without a timeout ... why can it not detect that the pipe is write ready i.e parent can write to it ... if it does not detect tha read pipe as having data...

View 5 Replies View Related

General :: Child Process Does Not Core Dump

Jul 27, 2011

In my program, I fork() to get a child process. Because of some problem, child process terminates by a segmentation fault. Parent process is still running. I have compiled my code with -g option. I have done: ulimit -c unlimited. I am not getting core dump of the child process. How can I get the core dump of child process?

View 1 Replies View Related

General :: Command Line For Child Process

May 20, 2011

I have created three child process from one parent. And different child has different functions. Child 2 has got function to load file called "wc" to count file1 and and its required to get their files by command line arguments. I can get the files through command line but couldn't get the files when child 2 process start.

View 9 Replies View Related

General :: Running Program In Background In Child Emulator Process

Aug 26, 2009

I wonder how one can, if at all, run an X program in the background *in an emulator sub-shell process*. What I mean is to launch a program in an emulator, e.g, by xterm -e gedit

but with gedit (in this example) running in the background from inside the xterm sub-process, so that the xterm will accept other commands. In the above, gedit will run in the foreground, and of course, if you do
xterm -e gedit &

then xterm will run in the background, not gedit.In short, I would like to achieve the same thing as "gedit &" as you manually do in xterm, but from another shell. What I aim to do is write an X init script to achieve this result (to have the emulator open and a program or two running from it, in the background, at the X startup).

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved