Sponsored Content
Top Forums Programming Status of child job after parent is killed Post 302123774 by anjul_thegreat on Wednesday 27th of June 2007 07:35:01 AM
Old 06-27-2007
Status of child job after parent is killed

Hi,

I have a requirement.

Scenario:

A parent job invokes a child job and gets killed. The child becomes orphan and gets attached to init. Child job is removed from the pid table as soon as it gets completed.
Requirement is i need the status of the child job even after the parent job is completed in the second parent job invoked if the actual parent is killed.
 

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. Filesystems, Disks and Memory

How hard can it be? ps child/parent

:( Since I'm fairly new to the scene and don't have much experience in shell programming, I decided to check out the net for a useful script or two. What I'm looking for is a script that would let me enter a PID and then show the process tree associated with it. So it would display the (grand-)... (2 Replies)
Discussion started by: velde046
2 Replies

3. UNIX for Dummies Questions & Answers

kill parent and child

Hello all, I have gone through the search and looked at posting about idle users and killing processes. Here is my question I would like to kill an idle user ( which I can do) but how can I asure that all of his process is also killed whit out tracing his inital start PID. I have tried this on a... (4 Replies)
Discussion started by: larry
4 Replies

4. 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

5. UNIX for Dummies Questions & Answers

Who is the parent of a killed process ?

Suppose we have the following process tree: init-> ProcessA->processB->processC then I kill processB Who is the parent of the processC? init or the processA (6 Replies)
Discussion started by: Puntino
6 Replies

6. UNIX for Advanced & Expert Users

Child Killing Parent

Hi all, I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts. My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to... (4 Replies)
Discussion started by: mark007
4 Replies

7. Shell Programming and Scripting

Running at command - Parent script getting killed

I have a script that calls another script within it that takes about 1 hour to execute. I am noticing that the parent script that calls the child script is getting killed. Does anyone know why? The child script still runs. (3 Replies)
Discussion started by: 3junior
3 Replies

8. Homework & Coursework Questions

Need help with deleting childīs parent and child subprocess

1. The problem statement, all variables and given/known data: I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process. 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies

9. 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

10. Shell Programming and Scripting

Propagate exist status from a child shell script to a parent.

Hi All, I have a parent shell script A and a child shell script B. 1). If a command i.e a mysqdump fails in shell script B fails then I trap the error with this code if ] then func_exit "Failed to export the cleaned DB1.${MYDBNAME} database to the ${MYARCHIVEDIR} directory"... (1 Reply)
Discussion started by: daveu7
1 Replies
SETPGID(3P)						     POSIX Programmer's Manual						       SETPGID(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
setpgid - set process group ID for job control SYNOPSIS
#include <unistd.h> int setpgid(pid_t pid, pid_t pgid); DESCRIPTION
The setpgid() function shall either join an existing process group or create a new process group within the session of the calling process. The process group ID of a session leader shall not change. Upon successful completion, the process group ID of the process with a process ID that matches pid shall be set to pgid. As a special case, if pid is 0, the process ID of the calling process shall be used. Also, if pgid is 0, the process ID of the indicated process shall be used. RETURN VALUE
Upon successful completion, setpgid() shall return 0; otherwise, -1 shall be returned and errno shall be set to indicate the error. ERRORS
The setpgid() function shall fail if: EACCES The value of the pid argument matches the process ID of a child process of the calling process and the child process has success- fully executed one of the exec functions. EINVAL The value of the pgid argument is less than 0, or is not a value supported by the implementation. EPERM The process indicated by the pid argument is a session leader. EPERM The value of the pid argument matches the process ID of a child process of the calling process and the child process is not in the same session as the calling process. EPERM The value of the pgid argument is valid but does not match the process ID of the process indicated by the pid argument and there is no process with a process group ID that matches the value of the pgid argument in the same session as the calling process. ESRCH The value of the pid argument does not match the process ID of the calling process or of a child process of the calling process. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
The setpgid() function shall group processes together for the purpose of signaling, placement in foreground or background, and other job control actions. The setpgid() function is similar to the setpgrp() function of 4.2 BSD, except that 4.2 BSD allowed the specified new process group to assume any value. This presents certain security problems and is more flexible than necessary to support job control. To provide tighter security, setpgid() only allows the calling process to join a process group already in use inside its session or create a new process group whose process group ID was equal to its process ID. When a job control shell spawns a new job, the processes in the job must be placed into a new process group via setpgid(). There are two timing constraints involved in this action: 1. The new process must be placed in the new process group before the appropriate program is launched via one of the exec functions. 2. The new process must be placed in the new process group before the shell can correctly send signals to the new process group. To address these constraints, the following actions are performed. The new processes call setpgid() to alter their own process groups after fork() but before exec. This satisfies the first constraint. Under 4.3 BSD, the second constraint is satisfied by the synchronization property of vfork(); that is, the shell is suspended until the child has completed the exec, thus ensuring that the child has completed the setpgid(). A new version of fork() with this same synchronization property was considered, but it was decided instead to merely allow the parent shell process to adjust the process group of its child processes via setpgid(). Both timing constraints are now satisfied by having both the parent shell and the child attempt to adjust the process group of the child process; it does not matter which succeeds first. Since it would be confusing to an application to have its process group change after it began executing (that is, after exec), and because the child process would already have adjusted its process group before this, the [EACCES] error was added to disallow this. One non-obvious use of setpgid() is to allow a job control shell to return itself to its original process group (the one in effect when the job control shell was executed). A job control shell does this before returning control back to its parent when it is terminating or sus- pending itself as a way of restoring its job control "state" back to what its parent would expect. (Note that the original process group of the job control shell typically matches the process group of its parent, but this is not necessarily always the case.) FUTURE DIRECTIONS
None. SEE ALSO
exec(), getpgrp(), setsid(), tcsetpgrp(), the Base Definitions volume of IEEE Std 1003.1-2001, <sys/types.h>, <unistd.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 SETPGID(3P)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy