Project

General

Profile

[Solved] Disable SIGTERM and closing CGI pipes on system time change

Added by happy_driscoll almost 5 years ago

Is there a way to disable Lighttpd from sending a SIGTERM and closing its pipes to CGI processes after a large system time change?

I have a web page where the user can change the system time through a request. This request starts a CGI process to change the system time, but on large jumps forward (about 2 years), Lighttpd kills the CGI process and its pipe before CGI can respond with a success page. Lighttpd does not send a SIGTERM/kill pipes on smaller time changes (about < 2 years).

I believe the execution goes something like this:
  1. client requests to change time
  2. cgi process starts
  3. cgi process changes system time
  4. Lighttpd senses a large jump in time
  5. Lighttpd sends a SIGTERM to CGI processes and closes their communication pipes
  6. Partial or no response from CGI to the client

Dynamic backends such as fastcgi or scgi are not an option.

Thanks ahead of time for any help or advice you can give.

Info

Lighttpd Version: v1.4.51
OS: Linux
Modules: mod_cgi

Attempted solutions:

  • I've tried ignoring/handling the SIGTERM from Lighttpd to the CGI process, but the communication pipes are still closed, so I can not get a response back to the client.
  • I've tried setting server.max-keep-alive-idle, server.max-read-idle, and server.max-write-idle to several years. There was no change in behavior. I tested the config syntax with -t, and it was OK.

Replies (3)

RE: Disable SIGTERM and closing CGI pipes on system time change - Added by gstrauss almost 5 years ago

I have a web page where the user can change the system time through a request.

On well run systems, time is the first thing that is stable.

So much for that.

How about you send the response and then change the time?

RE: Disable SIGTERM and closing CGI pipes on system time change - Added by happy_driscoll almost 5 years ago

Thanks for the response!

I forgot to mention that sending a response before changing the time is my current solution. This has worked the majority of the time, but Lighttpd can still cut off the response content.

After writing to stdout, the CGI program continues to execute and change the time. However, Lighttpd does not move content from stdout to the client immediately, and this seems to occur asynchronously with the CGI process execution. There's still a window where CGI can change the time and be killed before Lighttpd writes all of the content to the client.

Thanks again for the suggestion.

RE: Disable SIGTERM and closing CGI pipes on system time change - Added by gstrauss almost 5 years ago

These answers should really be obvious to you, so please consider whether or not you should be writing code that modifies the system.

Your CGI could send a response, then fork and detach from the CGI procress, sleep a short while, e.g. 1 second, and then change the time.

Alternatively, your CGI should schedule an `at` job to update the time in a few seconds from now, then send a response.

    (1-3/3)