Sponsored Content
Top Forums Programming C function to start process but to return right away Post 302428068 by JCR on Tuesday 8th of June 2010 05:25:03 PM
Old 06-08-2010
It is a fastcgi program that interacts with a nginx webserver through a socket. I am using supervisord to spawn instances of this progam.
The number of loops could be infinite.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to start a process and make it sleep for 5 mins and then kill that process

how to start a process and make it sleep for 5 mins and then kill that process (6 Replies)
Discussion started by: shrao
6 Replies

2. Shell Programming and Scripting

return value of a function

Hi I have a doubt in the way the variables inside a function are treated . if a function is called from the main script directly, the variables inside them act as global variables. however if the return value of the function is stored to some other variable in the main script as shown,... (3 Replies)
Discussion started by: prez
3 Replies

3. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

4. Shell Programming and Scripting

return value of a function

I have write a shell function to get the maximum of a vector. However, the returned value from the function is not always the correct one. Here is the script: maxval() { local max j i size arrval size=$1 ; shift max=-999999999 i=0 while do arrval="$1" if then ... (5 Replies)
Discussion started by: fl0r10
5 Replies

5. Shell Programming and Scripting

return in function

I am using ksh. I want to know how can we make any function to return string or double value. I dont want to use the global variables. (5 Replies)
Discussion started by: PRKS
5 Replies

6. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

7. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

8. Shell Programming and Scripting

Pass return value of a function in background process

Hi, I have created a function f1 defined in script A.sh .I have called this function in background . But I want to use its return value for another function f2 in script A.sh. I tried declaring it as a global variable, yet it always returns the status as 0. Is there any way with which I can get... (7 Replies)
Discussion started by: ashima jain
7 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(2) 							System Calls Manual							   WAIT(2)

NAME
wait, waitpid - wait for process to terminate SYNOPSIS
#include <sys/types.h> #include <sys/wait.h> pid_t wait(int *status) pid_t waitpid(pid_t pid, int *status, int options) DESCRIPTION
Wait causes its caller to delay until a signal is received or one of its child processes terminates. If any child has died since the last wait, return is immediate, returning the process id and exit status of one of the terminated children. If there are no children, return is immediate with the value -1 returned. On return from a successful wait call, status is nonzero, and the high byte of status contains the low byte of the argument to exit sup- plied by the child process; the low byte of status contains the termination status of the process. A more precise definition of the status word is given in <sys/wait.h>. If wait can called with a null pointer argument to indicate that no status need be returned. Waitpid provides an alternate interface for programs that must not block when collecting the status of child processes, or that wish to wait for one particular child. The pid parameter is the process ID of the child to wait for, -1 for any child. The status parameter is defined as above. The options parameter is used to indicate the call should not block if there are no processes that wish to report status (WNOHANG), and/or that children of the current process that are stopped due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal should also have their status reported (WUNTRACED). (Job control is not implemented for Minix, but these symbold and signals are.) When the WNOHANG option is specified and no processes wish to report status, waitpid returns -1 with errno set to EAGAIN. The WNOHANG and WUNTRACED options may be combined by or'ing the two values. NOTES
The call wait(&status) is equivalent to waitpid(-1, &status, 0). See sigaction(2) for a list of termination statuses (signals); 0 status indicates normal termination. A special status (0177) is returned for a stopped process that has not terminated and can be restarted; see ptrace(2). If the 0200 bit of the termination status is set, a core image of the process was produced by the system. If the parent process terminates without waiting on its children, the initialization process (process ID = 1) inherits the children. <sys/wait.h> defines a number of macros that operate on a status word: WIFEXITED(status) True if normal exit. WEXITSTATUS(status) Exit status if the process returned by a normal exit, zero otherwise. WTERMSIG(status) Signal number if the process died by a signal, zero otherwise. WIFSIGNALED(status) True if the process died by a signal. WIFSTOPPED(status) True if the process is stopped. (Never true under Minix.) WSTOPSIG(status) Signal number of the signal that stopped the process. RETURN VALUE
If wait returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. Otherwise, a value of -1 is returned and errno is set to indicate the error. Waitpid returns -1 if there are no children not previously waited for, if the process that it wants to wait for doesn't exist, or if WNO- HANG is specified and there are no stopped or exited children. ERRORS
Wait will fail and return immediately if one or more of the following are true: [ECHILD] The calling process has no existing unwaited-for child processes. [EFAULT] The status argument points to an illegal address. [EAGAIN] Waitpid is called with the WNOHANG option and no child has exited yet. SEE ALSO
execve(2), exit(2), sigaction(2). 4th Berkeley Distribution June 30, 1985 WAIT(2)
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy