I have no idea about how this is expected to work in PHP, but with bash
it is expected that exec ls
closes the terminal. At least nothing here suggests that there is a memory leak.
The terminal closes because the process run by the terminal ends. The process run be the terminal is usually initially bash
, but if you exec
something, that something replaces bash
in the same process with whatever you ask it to run. So a plain ls
without exec
, bash
would start ls
as a child process and let it run to completion and then ask you to insert another command. With exec ls
your bash is no longer running when ls
is placed to run in the same process. Then when ls
pretty immediately completes itself and terminates, your terminal has no child process remaining and it will also terminate itself.
So again I must mention that I do not know if PHP has something called exec in it and if it has, I do not know what it does. This behavior of bash that is discussed above should not prevent you from launching programs from PHP. I must warn you that launching other full programs from a web page handler can have fairly severe security implications. Please be careful.