Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all calls to exit(3) from libavrdude library functions #774

Closed
dl8dtl opened this issue Dec 22, 2021 · 3 comments · Fixed by #1790
Closed

Remove all calls to exit(3) from libavrdude library functions #774

dl8dtl opened this issue Dec 22, 2021 · 3 comments · Fixed by #1790
Labels
enhancement New feature or request

Comments

@dl8dtl
Copy link
Contributor

dl8dtl commented Dec 22, 2021

(Previously, this had been marked as a "task" on Savannah, with nobody actually backing it.)
Quite some time ago, all the backend functionality of AVRDUDE had been moved out into libavrdude. The idea behind that was that the current src/main.c just describes one possible frontend, so it could be e.g. accompanied by a kind of GUI frontend as well.
However, some of the historic implementations gratuitously call exit() in case of a failure. This is fatal for a GUI application, which rather would prefer to give the user a kind of graphical response of the failure. Thus, call calls to exit() need to be converted into returning (and handling) an error code instead.

@mcuee
Copy link
Collaborator

mcuee commented Jun 7, 2022

Interesting background for the libavrdude.

In order for this idea to work, #952 (#954 is the same for Windows) needs to be fixed. The main problem is Windows.

@stefanrueger
Copy link
Collaborator

Converting exit(n) into return -n is relatively hard, as this may involve returning through a number of nested calls on the stack. I wonder whether setjmp()/longjmp() can provide a useful interface for the (weaker) aim of keeping the GUI alive so it can handle any problems gracefully. Converting exit() to longjmp() can be done with relative ease.

@mcuee mcuee changed the title Remove all calls to exit(3) from library functions Remove all calls to exit(3) from libavrdude library functions Jan 15, 2023
@mcuee
Copy link
Collaborator

mcuee commented Jun 27, 2023

Converting exit(n) into return -n is relatively hard, as this may involve returning through a number of nested calls on the stack. I wonder whether setjmp()/longjmp() can provide a useful interface for the (weaker) aim of keeping the GUI alive so it can handle any problems gracefully. Converting exit() to longjmp() can be done with relative ease.

Any new ideas about this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants