0

I'm writing/debugging a shell, in C, that runs on a while(1) loop, and every time I exit the shell, it closes the terminal, using exit(), that I used to run the executable so I constantly have to open another terminal and cd back to the directory of my workspace in order to continue working. I figured this would be a good reason to learn how I could open another terminal process at my current working directory.

PS. I know a better solution, for efficiency's sake, would be learning how to end my executable without closing my terminal, but that's not what I'm asking.

Chris Phillips
  • 1,997
  • 2
  • 19
  • 34

1 Answers1

2

In bash shell, execute bash to open a subshell before running your executable. Id est, run bash as the command you run before your executable. Thus, when your executable terminates itself and it's shell, only the subshell will be terminated.

bash -c name_of_your_executable

As you mention in your question, the better solution is to end your executable without terminating the shell as well.

Agi Hammerthief
  • 2,114
  • 1
  • 22
  • 38