# Strange problem with the functions exec() / system()...

- Thread: https://externals.io/message/22719
- Original archive: https://news-web.php.net/php.internals/22719
- Started by Michael Vergoz on 2006-04-12T13:45:11+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22719 — Michael Vergoz — 2006-04-12T13:45:11+00:00

URL: https://externals.io/message/22719#22719

Salut

I have a strange problem with the functions `exec()` / `system()`... 
I have a threaded  Web server which executes a script PHP executing itself another init.d script (/etc/init.d/apache start). 
When I stopped the Web server I can not bind() any more the port of this one. 
In fact I have the feeling that the kernel does not free the socket properly. 

Did somebody already face this problem?

Thanks

---

## #22818 — Wez Furlong — 2006-04-17T12:06:46+00:00

URL: https://externals.io/message/22719#22818 · In reply to: #22719

My hunch is that your sockets are being inherited by the child process(es).
You should look at setting the close-on-exec flag on your sockets.

--Wez.


> Salut
>
> I have a strange problem with the functions `exec()` / `system()`...
> I have a threaded  Web server which executes a script PHP executing itself another init.d script (/etc/init.d/apache start).
> When I stopped the Web server I can not bind() any more the port of this one.
> In fact I have the feeling that the kernel does not free the socket properly.
>
> Did somebody already face this problem?
>
> Thanks

---

## #22834 — Michael Vergoz — 2006-04-18T14:42:51+00:00

URL: https://externals.io/message/22719#22834 · In reply to: #22818

Yes thank you i have identify the problem.

----- Original Message ----- 
From: "Wez Furlong" <kingwez@gmail.com>
To: "Michael Vergoz" <mv-php@binarysec.com>
Cc: "PHPdev" <internals@lists.php.net>
Sent: Monday, April 17, 2006 2:06 PM
Subject: Re: [PHP-DEV] Strange problem with the functions `exec()` / 
 `system()`...


My hunch is that your sockets are being inherited by the child process(es).
You should look at setting the close-on-exec flag on your sockets.

--Wez.


> Salut
>
> I have a strange problem with the functions `exec()` / `system()`...
> I have a threaded  Web server which executes a script PHP executing itself 
> another init.d script (/etc/init.d/apache start).
> When I stopped the Web server I can not bind() any more the port of this 
> one.
> In fact I have the feeling that the kernel does not free the socket 
> properly.
>
> Did somebody already face this problem?
>
> Thanks
