Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atexit() not called when terminating mules (psgi) #990

Open
aldem opened this issue Jul 29, 2015 · 2 comments
Open

atexit() not called when terminating mules (psgi) #990

aldem opened this issue Jul 29, 2015 · 2 comments

Comments

@aldem
Copy link
Contributor

aldem commented Jul 29, 2015

Hi,

Not sure if this is a bug or intended behavior, but, unlike as for workers, atexit() hook is not called when mule is terminated, though postfork() is called as usual (tested on 2.0.11.1)

@unbit
Copy link
Owner

unbit commented Jul 30, 2015

Can you report your example config ?

@aldem
Copy link
Contributor Author

aldem commented Jul 30, 2015

Config is as simple as it can be: uwsgi --http-socket :9090 -L -M --mule --psgi uwsgi-dummy.pl

But after some investigation, it seems that I found how (but not why) this happens - I have $SIG{INT} handler set in postfork(), which prevents execution of atexit() in mule (though it does not prevent atexit() in worker).

What is a bit puzzling, though, is that this sigint handler is not called at all (but I can live with that). My sample code:

use strict;
use warnings;

uwsgi::log("[$$] Initializing\n");

uwsgi::postfork(sub {
    uwsgi::log("[$$]: postfork()\n");
    $SIG{INT} = sub {
        uwsgi::log("[$$] SIGINT received\n");
    };
});

uwsgi::atexit(sub {
    uwsgi::log("[$$]: atexit()\n");
});

my $app = sub {
    return [200, [ "Content-Type" => 'text/plain' ], ["There is nothing to see here, sorry\n"]];
};

And the output when killing:

...
[5298] Initializing
PSGI app 0 (uwsgi-d.pl) loaded in 0 seconds at 0x1804ab0 (interpreter 0x15ca5d0)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 5298)
spawned uWSGI worker 1 (pid: 5299, cores: 1)
[5299]: postfork()
spawned uWSGI mule 1 (pid: 5300)
[5300]: postfork()
^CSIGINT/SIGQUIT received...killing workers...
[5299]: atexit()
worker 1 buried after 1 seconds
goodbye to uWSGI.

No output from signal handler and from atexit() in mule. Tried this on CentOS 6 (perl 5.8) and CentOS 7 (perl 5.16), uwsgi 2.0.11.1 - same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants