Quote:
Originally Posted by
wisecracker
This was just an idea...
I wasn't actually asking anything. I was experimenting with generating an error code
system of my own with values outside of an 8 bit range.
I used the real 255 exit code as 'number out of range' flag and then generate a string
whilst exit is in process. This string was originally a number, but I decided to make it
a string instead, purely for fun.
I am not sure if this will work in any way: return codes are not coming out of thin air, but the result of a system call, as jim mcNamara has explained. It can't give you back more than it ought to. It is defined as an unsigned 8-bit integer, so it can't deliver a 16- (or 32-, 64-, ...) bit number, a string or whatever. This would mean that this value has to be put on the stack and then pulled off it by the wait() or waitpid()-function. As the function would not know that it is expected to get that off the stack it won't do it and the stack would be (and stay) subsequently corrupted.
If you want to have extended exit-messages of any sort - strings, numbers, whatever - you will have to use the classical means of conveying such messages: interprocess communication (aka semaphores, shared memory segments, ... - take your pick) or process-to-process I/O, like file descriptors and/or named pipes. Write to <stdout>, <stderr>, etc. and intercept this with pipes, I/O-redirection and the like.
Another option is to write to a log file of some sort and have that parsed from the calling process.
Quote:
Originally Posted by
wisecracker
Perhaps I shouldn't have posted it...
There is no harm done in discussing anything and i am convinced this board won't go down from 1k characters of non-conclusive discussion. Still, i think you should post such topics (and the likes - you seem to enjoy exploring the limits of the OS in general and the shell in specific) not in the beginner forum. This is clearly not the stuff someone who learned the shell yesterday asks first. Please consider moving to the experts forum for topics like this.
I hope this helps.
bakunin