Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-07

SIGTERM and thread

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

jmbottu

Hello,
I wrote a handler to intercept the SIGTERM signal and execute some processing before terminating the program.
It works fine.

But when i add the cthreads unit in the uses clause, the application seems to do a shutdown after the end of the handler function, and the processing before terminating the program can no longer run.

Thanks in advance for your help.
Jean-Marc

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/SIGTERM-and-thread-tp5710294.html Sent from the Free Pascal - General mailing list .
Jorge Aldo G. de F. Junior
to jmbottu

Did you try a simpler handler ?

Maybe just set a variable and exit. Just a kind of test case...

2012/7/11 jmbottu :

Show quoted text 18 lines
Hello, I wrote a handler to intercept the SIGTERM signal and execute some processing before terminating the program. It works fine. But when i add the cthreads unit in the uses clause, the application seems to do a shutdown after the end of the handler function, and the processing before terminating the program can no longer run. Thanks in advance for your help. Jean-Marc -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/SIGTERM-and-thread-tp5710294.html Sent from the Free Pascal - General mailing list . _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Mark Morgan Lloyd
to jmbottu: I wrote a handler to intercept the SIGTERM signal and execute some processing before…
jmbottu wrote 8 lines
Hello, I wrote a handler to intercept the SIGTERM signal and execute some processing before terminating the program. It works fine. But when i add the cthreads unit in the uses clause, the application seems to do a shutdown after the end of the handler function, and the processing before terminating the program can no longer run.

What's in the handler? I usually just use it to set a variable, since the CPU context at the time of the signal is unclear (i.e. might not be safe to perform a GUI op, don't know which thread was running at the time, might already be inside a non-reentrant function, and so on).

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
jmbottu
to Mark Morgan Lloyd

In the handler i just set a variable.
I have solved my problem in setting my own handler later in the application, after having started the threads.
It seems there is another handler which is setting when i use threads and that starts a shutdown of the application when receiving SIGTERM.

Thank you for your replies.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/SIGTERM-and-thread-tp5710294p5710300.html Sent from the Free Pascal - General mailing list .