[SOLVED] Writing a shell program in C. How to EXIT?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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 implementing the exit function in my custom shell program. When I input exit however, it does not return to the initial command terminal. I would really appreciate if anyone can tell me what I am doing wrong. Here is my code:
It is just showing the command prompt, instead of exiting to the terminal prompt. But I think I have figure out why. I think it is because when I input a command like "cd" or "pwd", the position at args[0] stores it, and is not overwritten by exit. I need to figure a way to to overwrite it.
It is just showing the command prompt, instead of exiting to the terminal prompt. But I think I have figure out why. I think it is because when I input a command like "cd" or "pwd", the position at args[0] stores it, and is not overwritten by exit. I need to figure a way to to overwrite it.
Sorry if I am not clearly communicating.
Do not worry. But you provided a missing piece of information, in deed. ;-)
Have you seen the manpage on exit (man 3 exit)? I am not in your project, but feel that there is some nice hint for you in the documentation for the command. You may need to “prepare” the call to exit in a way that will permit the termination of the program in the way you want.
It is just showing the command prompt, instead of exiting to the terminal prompt. But I think I have figure out why. I think it is because when I input a command like "cd" or "pwd", the position at args[0] stores it, and is not overwritten by exit. I need to figure a way to to overwrite it.
Sorry if I am not clearly communicating.
before calling exit, reset it to where ever or whatever this terminal prompt is then call exit?
these two terms are euphemisms
a command prompt is within the terminal, hense it can be called a terminal prompt. so thats confusing me.
:-)) When krapykreme writes about her/his “custom shell program” you should just read “shell”, i.e. a kind of replacement for bash, dash and the like, probably with custom behaviour and not “full-featured”. It renders the exit() in deed quite interesting, though not overly complicated.
But I wondered in the same way, at first.
Last edited by Michael Uplawski; 02-13-2016 at 01:40 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.