OiO.lk Blog C++ C & Unix on Kubernetes – exit(0) doesn't work
C++

C & Unix on Kubernetes – exit(0) doesn't work


I tried to run my C-program on my local kubernetes-cluster and on the first look all functions are working as I expect.
Only my signal-handler for terminating one process doesn’t work completely.

There are two processes, one for administration, one for the "work". The administration-process sends a SIGTERM to the worker-process and the signal-handler also catch this signal (I can see it in my logs). The only thing that does not work: terminating the worker-process.

Here the signal-handler:

void handle_sigterm() {
error_msg(sip_man_log, "(MAIN) INFO: Closing all sockets.");
close(connfd); 
close(sockfd); 
close(sockfd_ext);
free_manipulation_table(int_modification_table);
free_manipulation_table(ext_modification_table); 
free_manipulation_table(mir_modification_table);

error_msg(sip_man_log, "(MAIN) INFO: Terminating Server by SIGTERM"); 
exit(0);} 

In the logs the last message is visible but the process is still active so I think the "exit(0);" does not work correctly (on my mind the "exit(0)" should terminate the complete process).

If I try the same code on my local machine it works as I expect. I’m relative new in C and Unix-programming so I don’t understand whats wrong here.

Thanks for your help!

Dennis



You need to sign in to view this answers

Exit mobile version