Background processes return 127 sporadically


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Background processes return 127 sporadically
# 1  
Old 05-22-2003
Data Background processes return 127 sporadically

I have created a shell script that spawns multiple background processes (spawns sqlplus application). I use an array to capture the process id of those background processes. I then loop through the array and issue a 'wait' command to wait on the process id that was captured in the array. I am getting sporadic results where some of the background processes return an exit code of 127.

It seems possible that it may be related to the OS because I get different results on different machines. Sun OS 5.6 I get sporadic results. Sun OS 5.8 seems to be OK.

Output results to show inconsitency:
--Run 1
Process: 0 PID: 13718 Return Value of: 0
Process: 1 PID: 13721 Return Value of: 0
Process: 2 PID: 13724 Return Value of: 0
Process: 3 PID: 13727 Return Value of: 127
Process: 4 PID: 13730 Return Value of: 0
--Run 1
Process: 0 PID: 20849 Return Value of: 0
Process: 1 PID: 20852 Return Value of: 127
Process: 2 PID: 20855 Return Value of: 127
Process: 3 PID: 20858 Return Value of: 127
Process: 4 PID: 20861 Return Value of: 0
--Run 1
Process: 0 PID: 21688 Return Value of: 0
Process: 1 PID: 21691 Return Value of: 0
Process: 2 PID: 21694 Return Value of: 127
Process: 3 PID: 21697 Return Value of: 0
Process: 4 PID: 21700 Return Value of: 0
--Run 1
Process: 0 PID: 23945 Return Value of: 0
Process: 1 PID: 23948 Return Value of: 0
Process: 2 PID: 23951 Return Value of: 0
Process: 3 PID: 23954 Return Value of: 0
Process: 4 PID: 23957 Return Value of: 0

Any ideas?????
# 2  
Old 05-22-2003
I'd guess the processes with those PIDs that returned a value of 127 are finishing before your wait command executes.. the sql applications you're spawning sometimes run faster and sometimes run slower..
Code:
0
Successful completion.

1-126
An error occurred.

127
A specified pid or job-id has terminated or is unknown by the invoking shell.

> 128
If a signal terminated the process abnormally, the exit status is a value
greater than 128 unique to that signal.


Last edited by oombera; 05-22-2003 at 02:41 PM..
# 3  
Old 05-22-2003
Tested your theory. Interesting results.

Created this script
#!/bin/ksh
echo 'Start'
sleep 6 &
RETVAL1=$!
sleep 4 &
RETVAL2=$!
sleep 2 &
RETVAL3=$!
wait $RETVAL1
echo $?
wait $RETVAL2
echo $?
wait $RETVAL3
echo $?
echo 'Finish'

Solaris 2.6 returned
Start
0
127
127
Finish

Solaris 2.8 returned
Start
0
0
0
Finish.

Looks like I have OS issues.

Thanks.

Last edited by max_largo; 05-22-2003 at 06:07 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

List all background processes

How do I list the process in a Unix based system which are running in background? The following are options that I'm aware of, but they may not be appropiate. a. using ps -ef , and getting records of processes for which STATUS='S'(uninterruptible sleep) b. using jobs -l, and filtering... (5 Replies)
Discussion started by: kumarjt
5 Replies

2. UNIX for Advanced & Expert Users

wait - return code 127

Hi All, I am trying to create background processes and then check their status later. But I am getting return codes as 0,127 randomly On checking the return codes for wait, I found the below. Do I need to treat return code of 127 as successful as well?? as we know the process id passed is... (7 Replies)
Discussion started by: tostay2003
7 Replies

3. Shell Programming and Scripting

Need help on background processes

Hi, I have a schell script parent.ksh from which I am calling three background processes a.ksh,b.ksh and c.ksh. Once these three processes completes the next step in parent.ksh should execute. How to achieve this? Please help me.... Thanks... (1 Reply)
Discussion started by: ravinunna
1 Replies

4. Shell Programming and Scripting

Background Processes

Ok guys so I have my first dummy shell almost done except for one tiny part: I do not know how to run a process in the background, from the code! I already know how to do that in a normal shell: $ program & However, no clue when it comes to how to program that thing. :eek: A very... (2 Replies)
Discussion started by: Across
2 Replies

5. Solaris

About running processes in background

Hi, I need to establish a procedure that will start an application in background each time my remote Solaris server is (re)started. This would be a kind of daemon. I am no sysadmin expert, so I am looking for pointers. How should I proceed? What are the main steps? Thanks, JVerstry (9 Replies)
Discussion started by: JVerstry
9 Replies

6. UNIX for Dummies Questions & Answers

Disadvantage of background processes

Hi, Inorder to improve the performance, I am trying to execute my command as a background process.. For eg: To zip large numbers of files present in a directory instead of using a single process, i do follow the below method: gunzip -c > / &... (3 Replies)
Discussion started by: unni.raj
3 Replies

7. Linux

Question about background processes

Hi! First of all, let me warn you I'm quite new to the world of LINUX and Operating Systems understanding, so that's why I pose these newbie and stupid qustions... Anyway, I'm trying to build my own simple shell in C and I'm getting some problems in implementing the background process ('&')... (10 Replies)
Discussion started by: neimaD
10 Replies

8. Shell Programming and Scripting

Checking Return Codes of Background Processes

I'm trying to do the following: 1) Run a bunch of jobs in the background 2) Determine if any one of them returns with a non-zero exit status Here's what I've come up with so far: ########################################## #!/bin/ksh while } -lt 1024 ] do SLEEP_TIME=`expr 1024 -... (2 Replies)
Discussion started by: bergerj3
2 Replies

9. Shell Programming and Scripting

Running two processes in background

hi there, here's what i need in my korn-shell: ... begin korn-shell script ... nohup process_A.ksh ; nohup process_B.ksh & ... "other stuff" ... end lorn-shell script in plain english i want process A and process B to run in the background so that the script can continue doing... (6 Replies)
Discussion started by: jacob_gs
6 Replies

10. UNIX for Advanced & Expert Users

Background processes

How do you capture the return code from a background process? I am dumping data to a fifo and then processing it in a c program. I need to know that the sql finished successfully to ensure no missing data. Thanks. ex. sqlplus user/password < get_data.sql > data_fifo.txt & bin/process_data... (2 Replies)
Discussion started by: korndog
2 Replies
Login or Register to Ask a Question