Feature #2007

Provide a mechanism for waiting until a termination request (e.g. SIGINT) arrives

Added by J. Moringen about 7 years ago. Updated about 7 years ago.

Status:ResolvedStart date:09/16/2014
Priority:NormalDue date:
Assignee:J. Moringen% Done:

100%

Category:Operating System Abstraction
Target version:Robotics Service Bus - rsb-0.11

Description

Interface

void initSignalWaiter(int signals)
Signal waitForSignal()

Implementation
  • Linux: signal handler and pthread semaphore
  • MacOS: similar
  • Win32: ?

sem.c Magnifier (1.43 KB) J. Moringen, 09/16/2014 08:33 PM


Related issues

Related to Robotics Service Bus - Tasks #2011: Update examples and documentation to use rsc::misc::{wait... Resolved 09/19/2014
Blocks Robotics Service Bus - Bug #2008: Clean up and exit properly when receiving SIG{INT,TERM} Resolved 09/17/2014

Associated revisions

Revision 6fbcf556
Added by J. Moringen about 7 years ago

Interface for waiting on termination signals in src/rsc/misc/SignalWaiter.h

refs #2007

  • src/rsc/misc/SignalWaiter.h: new file; contains interface for waiting
    on termination signals
  • examples/SignalWaiter.cpp: new file; example demonstrating the new
    interface

Reviewed-by: Johannes Wienke <>

Revision ada2913a
Added by J. Moringen about 7 years ago

POSIX implementation of termination signal waiting in src/rsc/misc/PosixSignalWaiter.cpp

refs #2007

  • src/rsc/misc/POSIXSignalWaiter.cpp: new file; contains POSIX
    implementation of the termination signal waiting interface
  • src/CMakeLists.txt: added file src/rsc/misc/POSIXSignalWaiter.cpp

Reviewed-by: Johannes Wienke <>

Revision 097ccb4a
Added by J. Moringen about 7 years ago

Win32 implementation of termination signal waiting in src/rsc/misc/Win32SignalWaiter.cpp

refs #2007

  • src/rsc/misc/Win32SignalWaiter.cpp: new file; contains implementation
    stub for Win32 of the termination signal waiting interface
  • src/CMakeLists.txt: added file src/rsc/misc/Win32SignalWaiter.cpp

Revision 9d0ab628
Added by J. Wienke about 7 years ago

Added Mac implementation for signal waiting

fixes #2007

  • src/rsc/misc/MacSignalWaiter.cpp: new file with new implementation
  • src/CMakeLists.txt: added a complete new branch to select mac
    implementations

Reviewed-by: Jan Moringen <>

Revision d07c50aa
Added by J. Moringen about 7 years ago

Enforce order of initSignalWaiter, waitForSignal calls in src/rsc/misc/*SignalWaiter.cpp

refs #2007

  • src/rsc/misc/PosixSignalWaiter.cpp (requestedSignals): new variable;
    stores requested signals
    (initSignalWaiter): store requested signals in requestedSignals
    (waitForSignal): check requestedSignals and throw an exception if it
    has not been set
  • src/rsc/misc/MacSignalWaiter.cpp: similar
  • src/rsc/misc/Win32SignalWaiter.cpp: similar

Revision f3afea92
Added by J. Moringen about 7 years ago

Added hasSignalArrived in src/rsc/misc/SignalWaiter.h

refs #2007

  • src/rsc/misc/SignalWaiter.h (hasSignalArrived): new function; return
    true if one of the requested signals has arrived
  • src/rsc/misc/PosixSignalWaiter.cpp (receivedSignal): initialize to 0
    (hasSignalArrived): new function; check receivedSignal variable to
    determine return value
  • src/rsc/misc/MacSignalWaiter.cpp: similar
  • src/rsc/misc/Win32SignalWaiter.cpp (receivedSignal): new function;
    stub

History

#1 Updated by J. Moringen about 7 years ago

  • Assignee changed from J. Moringen to J. Wienke

Please add the MacOS implementation :)

#2 Updated by J. Moringen about 7 years ago

  • File sem.cMagnifier added
  • % Done changed from 40 to 60

The existing code is in the feature-2007 branch.

Our MacOS experiments are in the attached file.

#3 Updated by J. Moringen about 7 years ago

  • Blocks Bug #2008: Clean up and exit properly when receiving SIG{INT,TERM} added

#4 Updated by J. Wienke about 7 years ago

  • Assignee changed from J. Wienke to J. Moringen
  • % Done changed from 60 to 80

I pushed a quick implementation. Could you please review it, especially the CMake changes.

Windows (non-support) is still missing.

#5 Updated by J. Moringen about 7 years ago

  • % Done changed from 80 to 90

I force-pushed some very minor modifications. Since the merge simulator jobs broke, i cannot check whether everything still builds.

Apart from that, we an probably add this to master tomorrow.

#6 Updated by J. Wienke about 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 90 to 100

#7 Updated by J. Moringen about 7 years ago

  • Related to Tasks #2011: Update examples and documentation to use rsc::misc::{waitForSignal,lastArrivedSignal} added

Also available in: Atom PDF