[yast-devel] [PATCH] yast2 exit codes
Hi! This is a long standing issue: the YCP clients cannot set the exit code for the yast2 process. This makes a big piece of command line functionality unusable. Attached patch implements the following behavior: Exit codes: 0 - everything fine 1 - too few arguments 5 - error in arguments 16 - generic client error 16 + x - client returned 'x' as exit code This is not exactly nice, but it keeps backward compatibility with the already returning exit codes. Basically, if error code is >0 and < 16, this is parameter handling error. if >= 16, you get the exit code by subtracting 16. 0 means no errors. Clients can return only 2 types of exit codes: boolean: true - exit code 0 false - exit code 16 integer: 16 + value Examples: return nil; => exit code 0 return; => exit code 0 return true; => exit code 0 return false; => exit code 16 return "true"; => exit code 0 (it's string!) return 2; => exit code 18 return -15; => exit code 1 return -100; => exit code 172 (process exit code is unsigned) If there are no objections, I will commit the patch + documenting the behavior in man page and in the generated docs. Stano
On čt 25. září 2008, Stanislav Visnovsky wrote:
Clients can return only 2 types of exit codes:
boolean: true - exit code 0 false - exit code 16
integer: 16 + value
Currently, some clients (esp. installation ones) return symbol. j -- Jiri Suchomel SUSE LINUX, s.r.o. e-mail: jsuchome@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Praha 9, Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dňa Thursday 25 September 2008 13:57:41 Jiří Suchomel ste napísal:
On čt 25. září 2008, Stanislav Visnovsky wrote:
Clients can return only 2 types of exit codes:
boolean: true - exit code 0 false - exit code 16
integer: 16 + value
Currently, some clients (esp. installation ones) return symbol.
How would you map symbol to integer? The patch handles symbols as exit code 0. Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Stanislav Visnovsky wrote:
Dňa Thursday 25 September 2008 13:57:41 Jiří Suchomel ste napísal:
On čt 25. září 2008, Stanislav Visnovsky wrote:
Clients can return only 2 types of exit codes:
boolean: true - exit code 0 false - exit code 16
integer: 16 + value Currently, some clients (esp. installation ones) return symbol.
How would you map symbol to integer? The patch handles symbols as exit code 0.
What about `abort, `cancel? That doesn't sound good for exit code 0. L.
Dňa Thursday 25 September 2008 14:11:45 Lukas Ocilka ste napísal:
Stanislav Visnovsky wrote:
Dňa Thursday 25 September 2008 13:57:41 Jiří Suchomel ste napísal:
On čt 25. září 2008, Stanislav Visnovsky wrote:
Clients can return only 2 types of exit codes:
boolean: true - exit code 0 false - exit code 16
integer: 16 + value
Currently, some clients (esp. installation ones) return symbol.
How would you map symbol to integer? The patch handles symbols as exit code 0.
What about `abort, `cancel? That doesn't sound good for exit code 0.
If we can come up with a mapping, it's trivial to add. Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dňa Thursday 25 September 2008 14:11:45 Lukas Ocilka ste napísal:
Stanislav Visnovsky wrote:
Dňa Thursday 25 September 2008 13:57:41 Jiří Suchomel ste napísal:
On čt 25. září 2008, Stanislav Visnovsky wrote:
Clients can return only 2 types of exit codes:
boolean: true - exit code 0 false - exit code 16
integer: 16 + value
Currently, some clients (esp. installation ones) return symbol.
How would you map symbol to integer? The patch handles symbols as exit code 0.
What about `abort, `cancel? That doesn't sound good for exit code 0.
Proposal: `abort => exit code 16 `cancel => exit code 16 Anything else? Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Donnerstag, 25. September 2008, Stanislav Visnovsky wrote:
Exit codes: 0 - everything fine 1 - too few arguments 5 - error in arguments 16 - generic client error 16 + x - client returned 'x' as exit code
By lucky coincidence, the UI uses exit codes that are consistent with this: YUIComponent::setServerOptions(...) { ... else if ( strcmp( argv[i], "--macro" ) == 0 ) { if ( i+1 >= argc ) { y2error( "Missing arg for '--macro'" ); fprintf( stderr, "y2base: Missing argument for --macro\n" ); exit( 1 ); } } void YUI::topmostConstructorHasFinished() { ... if ( _withThreads ) { if ( pipe( pipe_from_ui ) == 0 && pipe( pipe_to_ui ) == 0 ) { ... } else { yuiError() << "pipe() failed: errno: " << errno << " " << strerror( errno ) << endl; exit(2); } } But we should remain aware that there might be more reasons for some part of that complex framework to prematurely call exit(). Most of them are very pathological cases, but they might still happen, and we should be careful to avoid reporting them in misleading ways -- e.g., as "bad parameters" when some syscall early in the start-up process failed. CU -- Stefan Hundhammer <sh@suse.de> Penguin by conviction. YaST2 Development SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) Nürnberg, Germany -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dňa Thursday 25 September 2008 14:23:09 Stefan Hundhammer ste napísal:
On Donnerstag, 25. September 2008, Stanislav Visnovsky wrote:
Exit codes: 0 - everything fine 1 - too few arguments 5 - error in arguments 16 - generic client error 16 + x - client returned 'x' as exit code
By lucky coincidence, the UI uses exit codes that are consistent with this:
YUIComponent::setServerOptions(...) { ... else if ( strcmp( argv[i], "--macro" ) == 0 ) { if ( i+1 >= argc ) { y2error( "Missing arg for '--macro'" ); fprintf( stderr, "y2base: Missing argument for --macro\n" ); exit( 1 ); } }
void YUI::topmostConstructorHasFinished() { ... if ( _withThreads ) { if ( pipe( pipe_from_ui ) == 0 && pipe( pipe_to_ui ) == 0 ) { ... } else { yuiError() << "pipe() failed: errno: " << errno << " " << strerror( errno ) << endl; exit(2); } }
But we should remain aware that there might be more reasons for some part of that complex framework to prematurely call exit(). Most of them are very pathological cases, but they might still happen, and we should be careful to avoid reporting them in misleading ways -- e.g., as "bad parameters" when some syscall early in the start-up process failed.
Yes. Sounds like having the enum with standard ones in genericfrontend.cc is not a good idea - we need header file and require all exit() calls to use values from the enum there. Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hi! Here is updated patch. Changes: * exit codes are in y2/exitcodes.h header now * `abort and `cancel are handled as client errors, returning 16 Let me know if something is still missing. Stano
Dňa Friday 26 September 2008 08:59:25 Stanislav Visnovsky ste napísal:
Hi!
Here is updated patch. Changes:
* exit codes are in y2/exitcodes.h header now * `abort and `cancel are handled as client errors, returning 16
Let me know if something is still missing.
This is now submitted to Factory. Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
Jiří Suchomel
-
Lukas Ocilka
-
Stanislav Visnovsky
-
Stefan Hundhammer