Ask Your Question

Has 'exec' a memory leak on Fedora28?

asked 2018-08-02 09:26:22 -0600

achimae gravatar image

If I try to use exec on my new Fedora installation it will just crash and the terminal will disappear:

exec ls

This just works on my other Linux Systems. Even using ulimit doesn't change this behaviour a bit:

ulimit -m 64000; exec ls

I need that to make calls from my PHP-Scripts. Any solution or hint for further debugging would be helpful.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-08-02 14:38:53 -0600

muep gravatar image

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.

edit flag offensive delete link more


The bash behavior occurs in Fedora 27 and 24 as well.

wallyk gravatar imagewallyk ( 2018-08-03 02:50:42 -0600 )edit

answered 2018-08-08 11:59:22 -0600

achimae gravatar image

Thanks for the detailed answer on the behaviour of exec. So most systems seem tor fork first. The PHP problem was "just" the memory limit for php,(set in php.ini) just for the reference

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-08-02 09:26:22 -0600

Seen: 70 times

Last updated: Aug 02 '18