Sponsored Content
Full Discussion: printing ppid,child pid,pid
Top Forums Programming printing ppid,child pid,pid Post 47047 by a25khan on Monday 2nd of February 2004 12:13:37 AM
Old 02-02-2004
Computer

perderabo
actually i jus figured it out! thanks to you. you were a great help!
Cheers
a25khanSmilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to kill all child process for a given PID

Is there any build in command in unix to kill all the child process for a given process ID ? If any one has script or command, please let me know. Thanks Sanjay (4 Replies)
Discussion started by: sanjay92
4 Replies

2. Programming

Child Process PID

Hi, Can anybody solve this query? A parent process forks 2 child processes. How does the child process know it's PID without the parent process sending it. Apart from the "ps-ef" option, what other options are there if any? (2 Replies)
Discussion started by: skannan
2 Replies

3. UNIX for Advanced & Expert Users

strange pid and ppid problem

Hi all, Please look into the following code : int main() { char command; int pid, ppid; ppid = getpid(); /* Get the parent pid */ pid = fork(); /* Fork */ if ( pid ==0 ) { sprintf( command, " gdb a.out %d ", ppid ); printf( "Command line is %s\n", command ); system( command... (3 Replies)
Discussion started by: asvija
3 Replies

4. Shell Programming and Scripting

In ksh, how does an in-line child sub-process get its own PID?

This is not the same as a few of the other posted items dealing with sub-process pids (that I saw anyway). If zot contains: echo "main mypid: $$ - lastpid: $!" ( echo "block mypid: $$ - lastpid: $! - ppid: $PPID" ps -ef > xxx sleep 5 echo "block mypid: $$ - lastpid: $! - ppid:... (6 Replies)
Discussion started by: MichLab
6 Replies

5. Shell Programming and Scripting

child pid in ZSH

I am using ZSH shell in Linux. I am calling a child program in background mode parallely (say 2-3 threads). I have problem in handling the temporary files of these child programs since the temp file names are unique for all the child process. To distinguish i want to use the pid in the temp... (3 Replies)
Discussion started by: dhams
3 Replies

6. UNIX for Dummies Questions & Answers

Comparing CRON PID w/Current PPID

All, I've got a script that needs to check if it was started by cron. The code seems to be right, but it's not running correctly if cron starts it. Am I getting the pid's correctly? I'm not having any luck figuring it out. :confused: Any help is appreciated! CRON_ID=$(ps -aef | grep... (1 Reply)
Discussion started by: GregWold
1 Replies

7. Shell Programming and Scripting

how to capture PID for a child script

Hi, I'm looking for a method where we can capture the PID and if possible the progress of child process especially the ones running in background. can anyone help? (6 Replies)
Discussion started by: aman jain
6 Replies

8. UNIX for Dummies Questions & Answers

PID and PPID - please explain :(-

Hi, I need some help understanding PID and PPID that is shown by the ps -ef output. OS is Solaris 5.8. :wall: There are several Oracle databases and processes running on this server and they all have the same PPID. Does that mean they are all spawned off the same startup script? I then... (1 Reply)
Discussion started by: newbie_01
1 Replies

9. Red Hat

Listing all child pid and deleting it in reverse order

Hi , My problem is that I am not able to list all process id of any process. If you see pstree command it shows many process id under https. But if I run ps command its not listing all the process id for httpd. It is just listing the PPID and immediate child process id only. I... (4 Replies)
Discussion started by: pratapsingh
4 Replies

10. Shell Programming and Scripting

Getting child process id for a given PID

HI Am trying to get child process id for a PID using ksh.. ps -ef | grep xntpd root 3342472 2228308 0 12:17:40 - 0:00 /usr/sbin/xntpd root 4522024 6488316 0 12:18:56 pts/0 0:00 grep xntpd root 6291614 3342472 0 12:17:40 - 0:00 /usr/sbin/xntpd Here now i... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies
bind_to_cpu(3)						     Library Functions Manual						    bind_to_cpu(3)

NAME
bind_to_cpu - Bind execution to a specific CPU. LIBRARY
Mach Library (libmach.a) SYNOPSIS
#include <sys/types.h> #include <sys/resource.h> int bind_to_cpu( pid_t pid, unsigned long cpu_mask , unsigned long flag ); PARAMETERS
Specifies the target pid. You must have access rights to the pid. Specifies the CPU on which the thread should run. The target CPU is the bit index in the mask. If you set more than one bit, an error is generated. A cpu_mask of zero clears any previously set CPU binding. Specifies options to CPU binding. Currently only the option BIND_NO_INHERIT is supported. When set, this option causes child processes and threads to not inherit the CPU binding. DESCRIPTION
Upon return from bind_to_cpu, all threads of the target pid are running on the target CPU. Bound threads are not eligible for execution on any other CPU. You release CPU binding by invoking bind_to_cpu with a cpu_mask of zero. EXAMPLES
/* * Fork child process and force it to run on cpu number 3. * Processes created by the forked child will not inherit bindings. */ #include <sys/resource.h> #include <sys/sysinfo.h> #include <sys/signal.h> #include <sys/types.h> #define CPU_3 0x8 /* Bit 3 set */ main() { pid_t pid; if (pid = fork()) { /* parent */ if (bind_to_cpu(pid, CPU_3, BIND_NO_INHERIT)) { kill(pid, SIGKILL); exit(1); /* bind_to_cpu() will print error msg */ } sleep(2); /* wait for child to print CPU */ } else { /* child */ long cpu_num; sleep(1); /* wait for parent to bind CPU */ getsysinfo(GSI_CURRENT_CPU, &cpu_num, 0L, 0L, 0L); printf("child running on CPU %d ", cpu_num); } } In this example, the CPU_3 symbol is defined so that bit three in the bit mask is set. When the pid returned from the fork routine identi- fies the parent routine, the bind_to_cpu routine is called. This routine binds the child process to CPU number three, as specified in the CPU_3 symbol. When the pid returned from the fork routine identifies the child routine, the child routine sleeps to give the parent routine time to set its CPU binding. Then it uses the getsysinfo call to determine its CPU and displays its CPU with the printf routine. If the return value from the bind_to_cpu routine indicates an error, the parent process kills the child process and exits with an error status. RETURN VALUES
Upon successful completion, bind_to_cpu returns zero. Upon error, a -1 is returned. RELATED INFORMATION
Commands: runon(1) Functions: getsysinfo(2) delim off bind_to_cpu(3)
All times are GMT -4. The time now is 02:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy