Sponsored Content
Top Forums Shell Programming and Scripting Pass return value of a function in background process Post 302966646 by ashima jain on Monday 15th of February 2016 04:07:39 AM
Old 02-15-2016
Quote:
Originally Posted by RudiC
You can't pass variables back to the calling process. You can intercept the output and assing it to a variable.

What sense does it make to run a process in background and then wait for its status (and/or output)?

Its because the function f2 is function I have used to display status of the operations going on in function f1.
Can you explain "You can intercept the output and assing it to a variable."
How can we do the above?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

background process return code

Hi I have the following piece of code that is calling another child process archive.ksh in the background while read file; do file_name=`ls $file`; ksh archive.ksh $file_name &; done < $indirect_file The problem is, indirect_file may contain anwhere from 2 to 20 different... (5 Replies)
Discussion started by: Vikas Sood
5 Replies

2. Shell Programming and Scripting

How to include RETURN KEY with Background process "&" in Shell Script

Hello All, I am a newbie in Shell script programming, and maybe you can help me with my query. I need to write a shell script (mntServer.ksh) that will start a background process and also to be able to run another script. The mntServer.ksh script contains: #!/bin/ksh... (1 Reply)
Discussion started by: racbern
1 Replies

3. Shell Programming and Scripting

Return code of background process

Hi, I have a process that I run in the background that looks like this ${BASEDIR}/ksh/sqler.ksh ${compnames003} & and I would like to get the return code of the sqler.ksh script. so my code is like this ${BASEDIR}/ksh/sqler.ksh ${compnames003} & retcode=$? (3 Replies)
Discussion started by: c19h28O2
3 Replies

4. Programming

C function to start process but to return right away

Hello, I am using C on a Centos box with gcc as the compiler. I want a function to do something, them make an http request to some server (most probably using curl but suggestions are welcome) and return right away without waiting for the server's answer on that request. What should I use... (8 Replies)
Discussion started by: JCR
8 Replies

5. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

6. Shell Programming and Scripting

Background process, return code and pid.

Hey all, Okay, this one is tricky and I'm not sure there is a niec way to do it, or indeed anyway to do it. The main issue revolves around timing out a hung ssh. I am doing this by creating a wrapper script for the ssh with the following requirements. My requirements are: Defineable... (5 Replies)
Discussion started by: RECrerar
5 Replies

7. Shell Programming and Scripting

Capturing the return code from background process

Hi All, I was out not working on unix from quite sometime and came back recently. I would really appreciate a help on one of the issue I am facing.... I am trying to kick off the CodeNameProcess.sh in PARALLEL for all the available codes. The script runs fine in parallel. Let say there are... (1 Reply)
Discussion started by: rkumar28
1 Replies

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

9. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
wait(3C)						   Standard C Library Functions 						  wait(3C)

NAME
wait - wait for child process to stop or terminate SYNOPSIS
#include <sys/types.h> #include <sys/wait.h> pid_t wait(int *stat_loc); DESCRIPTION
The wait() function will suspend execution of the calling thread until status information for one of its terminated child processes is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process. If more than one thread is suspended in wait(), waitpid(3C), or waitid(2) awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination. If status information is available prior to the call to wait(), return will be immediate. If wait() returns because the status of a child process is available, it returns the process ID of the child process. If the calling process specified a non-zero value for stat_loc, the status of the child process is stored in the location pointed to by stat_loc. That status can be evaluated with the macros described on the wait.h(3HEAD) manual page. In the following, status is the object pointed to by stat_loc: o If the child process terminated due to an _exit() call, the low order 8 bits of status will be 0 and the high order 8 bits will con- tain the low order 7 bits of the argument that the child process passed to _exit(); see exit(2). o If the child process terminated due to a signal, the high order 8 bits of status will be 0 and the low order 7bits will contain the number of the signal that caused the termination. In addition, if WCOREFLG is set, a "core image" will have been produced; see sig- nal.h(3HEAD) and wait.h(3HEAD). One instance of a SIGCHLD signal is queued for each child process whose status has changed. If wait() returns because the status of a child process is available, any pending SIGCHLD signal associated with the process ID of that child process is discarded. Any other pending SIGCHLD signals remain pending. If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and the process has no unwaited children that were transformed into zombie processes, it will block until all of its children terminate, and wait() will fail and set errno to ECHILD. If a parent process terminates without waiting for its child processes to terminate, the parent process ID of each child process is set to 1, with the initialization process inheriting the child processes; see intro(2). RETURN VALUES
When wait() returns due to a terminated child process, the process ID of the child is returned to the calling process. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The wait() function will fail if: ECHILD The calling process has no existing unwaited-for child processes. EINTR The function was interrupted by a signal. USAGE
Since wait() blocks on a stopped child, a calling process wanting to see the return results of such a call should use waitpid(3C) or waitid(2) instead of wait(). The wait() function is implemented as a call to waitpid(-1, stat_loc, 0). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
intro(2), exec(2), exit(2), fork(2), pause(2), waitid(2), ptrace(3C), signal(3C), signal.h(3HEAD), waitpid(3C), wait.h(3HEAD), attributes(5) SunOS 5.10 9 Jun 2004 wait(3C)
All times are GMT -4. The time now is 08:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy