Sponsored Content
Top Forums Shell Programming and Scripting Return variable value from a script running in background Post 302748543 by rangarasan on Wednesday 26th of December 2012 06:24:30 AM
Old 12-26-2012
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to export a variable from a child process running in background to the parent

Hi All, I have a script which calls a child script with a parameter to be run in the background . childscript.ksh $a & Can any one suggest me how do i export a variable from the child script to parent script? Note that the child script is in background If the child script is in... (3 Replies)
Discussion started by: aixjadoo
3 Replies

2. Shell Programming and Scripting

How to stop the script which is running in background

Hi I have a script, which i ran in background, can someone please help in stopping this. i gave this command: ksh abc.ksh & this script sends me a mail every 30 seconds. i have deleted the script but still i am getting the mails. can some one please help me stopping dese. ... (3 Replies)
Discussion started by: Prateek007
3 Replies

3. UNIX for Advanced & Expert Users

send a new value to a variable in a running background process

Hi guys, I have a issue with a background process, I need to update the value of a variable in that process which is running at this time and it will be running for at least 2 days. Any idea? I will apreciate your help. regards. Razziel. (2 Replies)
Discussion started by: razziel
2 Replies

4. UNIX for Dummies Questions & Answers

Running the Script in Background.

Gurus, Pls. help on this to run the script in background. I have a script to run the informatica workflows using PMCMD in script. Say the script name is test.sh & Parameters to the script is Y Y Y Y The no of parameters to the bove script is 4. all are going to be a flags. Each flag will... (2 Replies)
Discussion started by: prabhutkl
2 Replies

5. UNIX for Advanced & Expert Users

Running script in background

When I run the following snippet in background #!/bin/ksh while do echo "$i" sleep 10 i=`expr $i + 1` done My job got stopped and it says like + Stopped (SIGTTOU) ex1 & I did "stty tostop" as suggested in many of the post but still not working... (3 Replies)
Discussion started by: shahnazurs
3 Replies

6. Shell Programming and Scripting

expect_out buffer no such variable running script background

I am trying to use send and receive using expect. the expect_out(buffer) is working fine while it is running it as foreground. But the same script when it is ran as background, the expect_out(buffer) errored out. Is there any factor influence when we run script in foreground and in background? ... (0 Replies)
Discussion started by: shellscripter
0 Replies

7. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

8. Shell Programming and Scripting

Export variable to another script running in background

i have a script inside which i have generated a background job which will run another script. How do i export the variables from parent script to the child script which wil run in the background . a.sh:- export tmpdir="/usr/tmp" nohup b.sh& b.sh:- echo $tmpdir But... (1 Reply)
Discussion started by: millan
1 Replies

9. Shell Programming and Scripting

Running script in background

Hi, I wrote a KSH script and running it on HP-UX machine I am running one script in background. My script is at location $HOME/myScript/test/background_sh When I view my script in background with psu commend > psu | grep background_sh I see following output UID PID PPID C ... (1 Reply)
Discussion started by: vaibhav
1 Replies

10. Shell Programming and Scripting

How to return from background process and check if it is running or not?

Hi Team, i am executing 3 scripts in background from 1 script and i want to send a message once the script gets completed.these scripts usually takes 1 hr to complete. My sample script is below, Vi abc.sh sh /opt/data/Split_1.sh & sh /opt/data/Split_2.sh & sh /opt/data/Split_3.sh & ... (3 Replies)
Discussion started by: raju2016
3 Replies
SETPGID(P)						     POSIX Programmer's Manual							SETPGID(P)

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(P)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy