Skip to main content

Visibroker 7: User application registered signal handler for SIGTERM is not effective

  • February 16, 2013
  • 0 replies
  • 0 views

Problem:

  • Product Name: VisiBroker for C
  • Product Version: 7.0 and SP1
  • Product Component: ORB
  • Platform/OS Version: Red Hat Enterprise Linux Release 4

The child process is unable to respond to SIGTERM signal.

C ORB in Visibroker 7 is using SIGWAIT method to block waiting for SIGINT and SIGTERM signals. According to man pages in RHEL Release 4, when SIGWAIT is used to block waiting for some signals then even if a signal handler registered via signal() for SIGTERM in the user application, it will not be called.

Sometimes, the ORB abort the application process when sigwait() returning non-zero status. This problem is discovered with the following RHEL Release 4 kernel,

Linux 2.6.9-22.EL #1 Mon Sep 19 17:49:49 EDT 2005 x86_64x86_64 x86_64 GNU/Linux

Resolution:

The following provides one solution for the existing user application to successfully re-registered their traditional signal handling routine, however, please take note such a way is not compliant to the POSIX standard usage. Please read the wiki article [[wiki: Signal handling in VisiBroker for C application (Part Two)]] for the correct and better approach.

int main (int, char**)
{
  // ORB initialization
  ...

  // unblock the signal registered by VisiBroker
  sigset_t sigset;

  sigemptyset(&sigset);
  sigaddset(&sigset, SIGTERM);
  sigprocmask(SIG_UNBLOCK, &sigset, NULL);

  // then register your handler
  signal(SIGTERM, &user_signal_handler);
  ...
  return 0;
}

The above code snippet illustrates how the user application could regain their registered signal handling routine.

  • Empty the signal set by,

sigemptyset(&sigset);

  • Add the interested signal into the set by,

sigaddset(&sigset, SIGTERM);

  • Sigprocmask() is used to change the list of currently blocked signal. The SIG_UNBLOCK will unblock the SIGTERM signal masked by VisiBroker through the pthread_sigmask(SIG_BLOCK,...),

sigprocmask(SIG_UNBLOCK, &sigset, NULL);

  • Install the new signal handler for SIGTERM,

signal(SIGTERM, &user_signal_handler);

 

In a scenario where the ORB assumes sigwait() is not returning any error and calls the abort() function and causing the process to crash is fixed with a later Red Hat kernel release,

Linux 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST 2006 x86_64 x86_64 x86_64 GNU/Linux.

See also the article [[knowledge_base: Signals that are handled by the VisiBroker]].


#Security
#VisiBroker