Sponsored Content
Top Forums Shell Programming and Scripting Get all child processes of a process Post 302974671 by MadeInGermany on Thursday 2nd of June 2016 04:03:43 AM
Old 06-02-2016
I usually have taken -e not -A for portable ps.
HP-UX needs environment variable UNIX95 to take the -o option.
If your pid is 4711 then a portable command to find its children is
Code:
UNIX95=1 ps -e -o ppid= -o args= | awk '$1==ppid' ppid=4711


Last edited by MadeInGermany; 06-02-2016 at 06:27 AM..
This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

I don't follow what these are... this is what my text says... "When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies

2. Programming

Controlling child processes

Hello all, I am trying to create n child processes and control them from a parent process; say make child 3 print its pid and then child 5 do the same and some other stuff. Is there a way to accomplishing this after all the child processes are created via a call to fork(). Thank you, FG (23 Replies)
Discussion started by: forumGuy
23 Replies

3. Shell Programming and Scripting

Parent/Child Processes

Hello. I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks (2 Replies)
Discussion started by: yoi2hot4ya
2 Replies

4. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

5. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

6. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

7. UNIX for Advanced & Expert Users

How to find all the child processes of a parent process

Hi I am trying to see if there are some options in ps command or if there is a shell script which basically shows you all the processes spawned by a parent process , then all the processes of its child processes and so on down the hierarchy may be like a tree structure. It might be a generic... (6 Replies)
Discussion started by: clifford
6 Replies

8. Shell Programming and Scripting

36 Child Processes not running as desired

I have a parent process which will start 36 child process. This I achieved by using the 'for loop'. In Parent.sh:- ./Child.sh <arg1> <arg2> ... & If I execute "ps -ef | grep Child.sh", I can see 72 child processes running at the background. I mean I can see the duplicate of each process. ... (2 Replies)
Discussion started by: nthiruvenkatam
2 Replies

9. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

10. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
tapset::context(3stap)													    tapset::context(3stap)

NAME
tapset::context - systemtap context tapset DESCRIPTION
Context functions provide additional information about where an event occurred. These functions can provide information such as a back- trace to where the event occurred and the current register values for the processor. print_regs Print a register dump See function::print_regs(3stap) for details. pp Returns the active probe point See function::pp(3stap) for details. ppfunc Returns the function name parsed from pp() See function::ppfunc(3stap) for details. probe_type The low level probe handler type of the current probe. See function::probe_type(3stap) for details. execname Returns the execname of a target process (or group of processes) See function::execname(3stap) for details. pid Returns the ID of a target process See function::pid(3stap) for details. tid Returns the thread ID of a target process See function::tid(3stap) for details. ppid Returns the process ID of a target process's parent process See function::ppid(3stap) for details. pgrp Returns the process group ID of the current process See function::pgrp(3stap) for details. sid Returns the session ID of the current process See function::sid(3stap) for details. pexecname Returns the execname of a target process's parent process See function::pexecname(3stap) for details. gid Returns the group ID of a target process See function::gid(3stap) for details. egid Returns the effective gid of a target process See function::egid(3stap) for details. uid Returns the user ID of a target process See function::uid(3stap) for details. euid Return the effective uid of a target process See function::euid(3stap) for details. is_myproc Determines if the current probe point has occurred in the user's own process See function::is_myproc(3stap) for details. cpuid Returns the current cpu number See function::cpuid(3stap) for details. cpu Returns the current cpu number See function::cpu(3stap) for details. registers_valid Determines validity of register() and u_register() in current context See function::registers_valid(3stap) for details. user_mode Determines if probe point occurs in user-mode See function::user_mode(3stap) for details. is_return Whether the current probe context is a return probe See function::is_return(3stap) for details. target Return the process ID of the target process See function::target(3stap) for details. module_name The module name of the current script See function::module_name(3stap) for details. stp_pid The process id of the stapio process See function::stp_pid(3stap) for details. remote_id The index of this instance in a remote execution. See function::remote_id(3stap) for details. remote_uri The name of this instance in a remote execution. See function::remote_uri(3stap) for details. stack_size Return the size of the kernel stack See function::stack_size(3stap) for details. stack_used Returns the amount of kernel stack used See function::stack_used(3stap) for details. stack_unused Returns the amount of kernel stack currently available See function::stack_unused(3stap) for details. addr Address of the current probe point. See function::addr(3stap) for details. uaddr User space address of current running task See function::uaddr(3stap) for details. cmdline_args Fetch command line arguments from current process See function::cmdline_args(3stap) for details. cmdline_arg Fetch a command line argument See function::cmdline_arg(3stap) for details. cmdline_str Fetch all command line arguments from current process See function::cmdline_str(3stap) for details. SEE ALSO
function::print_regs(3stap), function::pp(3stap), function::ppfunc(3stap), function::probe_type(3stap), function::execname(3stap), function::pid(3stap), function::tid(3stap), function::ppid(3stap), function::pgrp(3stap), function::sid(3stap), function::pexecname(3stap), function::gid(3stap), function::egid(3stap), function::uid(3stap), function::euid(3stap), function::is_myproc(3stap), function::cpuid(3stap), function::cpu(3stap), function::registers_valid(3stap), function::user_mode(3stap), function::is_return(3stap), function::target(3stap), function::module_name(3stap), function::stp_pid(3stap), function::remote_id(3stap), function::remote_uri(3stap), function::stack_size(3stap), function::stack_used(3stap), function::stack_unused(3stap), function::addr(3stap), function::uaddr(3stap), function::cmdline_args(3stap), function::cmdline_arg(3stap), function::cmdline_str(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::context(3stap)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy