![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Exit code 137 on a backup | twins | Filesystems, Disks and Memory | 4 | 03-27-2008 09:24 PM |
| problem with exit code when piping | bitoffish | Shell Programming and Scripting | 4 | 09-16-2007 07:21 PM |
| where can I get exit code meanings? | speedieB | Shell Programming and Scripting | 1 | 08-24-2006 11:38 AM |
| Where can I find a list of exit codes? (Exit code 64) | jkuchar747 | UNIX for Dummies Questions & Answers | 3 | 12-07-2004 06:08 PM |
| All about exit code | cdin2 | Shell Programming and Scripting | 2 | 03-11-2002 10:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Exit Code in HP-UX KSH.
In one of my programs another process is called using the system command e.g.
lv_error = system("myproc"); where lv_error is declared as an int. myproc would be returning 0 for success and 1 for failure. e.g. if (success) { return(0); }else{ return(1); } When the return code of myproc is examined in the shell via $? the value is reported correctly. When displayed in the calling C process a value of 0 or 1 is 256. The man documentation is not very clear. It seems that 256 may correspond to -1 return code and that I should do some more checking after that. Can anyone help? |
|
||||
|
Thanks. You are right about the -1 I was looking at something else!
The macro WEXITSTATUS didn't really make too much difference. The called process will always return a value of 256 (Prior to running my test I check what the called process will return by running it on its own). I must assume that since a -1 is not explictly being returned, the called process is being run successfully. Ok. With this in mind, I then replaced my called process with a dummy shell script which simply contained exit 0 or exit 1 depending on what condition I was testing. When the dummy script is used then I will get 0 returned for 0 and 256 returned for 1. At least I can make sense of these return codes! So the problem must be with the way the called process is returning its error code. To expand: if (success) { error = 0 }else{ error = 1 } ... return(error) where error is declared as an int. What am I doing wrong? } |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|