Skip to content

Commit

Permalink
Initialize cached oldAction before invoking OMRSIG_SIGACTION
Browse files Browse the repository at this point in the history
Before registering handlers using OMRSIG_SIGACTION,
oldActions[unixSignalNo].action (struct sigaction) needs to
be properly initialized or reset (in case of re-registration).

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Apr 9, 2018
1 parent ed5a742 commit 283d5aa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions port/unix/omrsignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,9 @@ registerSignalHandlerWithOS(OMRPortLibrary *portLibrary, uint32_t portLibrarySig
newAction.sa_sigaction = handler;
#endif

/* Initialize oldAction. */
memset(&oldActions[unixSignalNo].action, 0, sizeof(struct sigaction));

/* now that we've set up the sigaction struct the way we want it, register the handler with the OS */
if (OMRSIG_SIGACTION(unixSignalNo, &newAction, &oldActions[unixSignalNo].action)) {
Trc_PRT_signal_registerSignalHandlerWithOS_failed_to_registerHandler(portLibrarySignalNo, unixSignalNo, handler);
Expand Down

0 comments on commit 283d5aa

Please sign in to comment.