system() exit code
From: Stephen Morgan (nospam_at_nospam.com)
Date: 05/15/04
- Previous message: George Nelson: "Re: Allocating kernel memory"
- Next in thread: Lew Pitcher: "Re: system() exit code"
- Reply: Lew Pitcher: "Re: system() exit code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 May 2004 18:18:03 -0500
Hi all,
This script, call it "st"
#! /bin/sh
exit 123
exits with exit code of 123, as it should. However, this C code:
int rc;
rc = system("/root/yada/yada/st");
printf("return code is: %d\n", rc);
prints "return code is: 31488" which is 123 shifted left 8 bits. I've
tried this with a few values and the 8-bit shift is consistent.
Is this normal behavior for the system() function, and if so, is it
documented somewhere? Before I commit to code that relies on this behavior,
I'd like to know that it's reliable :-)
Thanks for your help,
Stephen Morgan
- Previous message: George Nelson: "Re: Allocating kernel memory"
- Next in thread: Lew Pitcher: "Re: system() exit code"
- Reply: Lew Pitcher: "Re: system() exit code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|