Re: [squid-users] redirect_program does not finish

From: Jan Humme <jan.humme@dont-contact.us>
Date: Thu, 18 Jul 2002 19:03:35 +0200

On Thursday 18 July 2002 15:49, Zé Luís wrote:
> Hi everybody
>
> I have this program that is executed in redirect_program it of squid.
> Redirect_children is 5
> As he can be seen I do not know I eat to make to stop up it when squid
> makes reconfigure/shutdown/restart/stop. This makes with that after a
> time it has many processes running.
> Which code would have that to insert below in the program so that it
> finished when squid to stop? (signal)

You may have noticed that it is not just that you will have many processes
running, but also they will start to consume an awfull amount of CPU-time
after squid dies!

An EOF condition occurs when squid stops running and closes the pipe to
stdin; as a result your call fgets(...) will return NULL from now on.

Unfortunately, you have embraced the while-loop with a for(;;)-loop, which
will keep the while-loop executing (and returning NULL) forever.

So just remove the embracing for(;;)-loop, such that the while-condition will
evaluate to FALSE as soon as fgets() returns NULL (ie. EOF), and your program
will terminate gracefully.

No murder (kill) needed!

Jan Humme.
Received on Thu Jul 18 2002 - 11:02:50 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:09:17 MST