ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello
I am programming , although not an expert , but , interested..anyway! sometimes when i run the compiled programs it seems that they are busy in the background! possibly trying to do the jobs that i have requested ...sometimes ..some programs just show an unreasonable delay and in some cases i understand that i have to close the terminal window and recompile them ..but they stand still!! so, i have to use ctrl + C command ...after that when i use the ("exit") command for bash i notice this message that (i ..myself have enable bash to notify it's exit status) : the program bash exited with the status of 127 or 130 0r at highest level 143..my question is that how do i terminate these programs to prevent suffering! of bash!..as i said i can not wait for ever or i am in a hurry to rewrite and recompile the new program ...terminating by system monitor ..etc show the same result ..here i want to emphasis that a very small percent of my programs act in this way ..most of them after doing all or some of their duties exit successfully!
Regards
why do you want to do that? this is the expected behaviour. (aborted program will cause a non-zero exit status).
Thank you for answering ...actually i knew that ..because i had studied a lot of pages found by Google search about bash exit status ..but i wonder because in the last lines of all my program codes i have set this code for exit status :
Even if in your programme, you code to trap each and every known error and have a default (unknown error), it is not guaranteed that it will be executed before the shell/gui encounters the error and abends leaving you with a non clean message. (Leading to suffering! of bash).
I do not understand that. Aborting a program means you will force the app to exit but the code you gave is not sufficient to handle that.... This is not the "normal" flow of the program.
I do not understand that. Aborting a program means you will force the app to exit but the code you gave is not sufficient to handle that.... This is not the "normal" flow of the program.
Would you please be more kind and show me a sufficient code for closing programs ..off course my code was longer than that and i abbreviated that
Even if in your programme, you code to trap each and every known error and have a default (unknown error), it is not guaranteed that it will be executed before the shell/gui encounters the error and abends leaving you with a non clean message. (Leading to suffering! of bash).
OK
Thank you for answering and for suggesting a site although i have seen that site before..
Up to now i know that :
exit status 127 , means command not found
exit status 130 or 128+n means program was closed with
Code:
//ctrl + c
exit status 143 was not directly or exactly mentioned but possibly could be in the range of 128+n
I am looking for a better way to make the newly compiled program to exit with no problem in such cases. Regards
Hi
I discovered that if after error-causing or problem-causing commands you do not use exit command directly , then maybe bash forgets or the effect of that problem disappears ...anyway use a known-successful command instead , then you may use : exit with possibly no problem
Thanks
It's not clear what your problem is, on the first place; so I cannot tell if your solution works or not.
I just want to answer you , otherwise it is not my problem anymore , because practically i see that my solution works
I was concerned about bash exit status which happened few times so i asked the question , but now whenever i think that bash might exit with a high integer status i use a command which i know that it will not return unwanted values ...for example : bash builtin commands then i use the exit command to quit/terminate bash...although still very very rare times the terminated child program or bash itself which is the parent of the terminated program crash! it is my programming mistakes which causes that and nearly inevitable! because humans make mistakes more than computers and super-humans ..etc
Thank you for your attention
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.