Skip to content

Commit

Permalink
ensure pid file is removed on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
furushchev committed May 23, 2017
1 parent be711cf commit d469733
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tools/roslaunch/src/roslaunch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,15 @@ def main(argv=sys.argv):
# This is a roslaunch parent, spin up parent server and launch processes.
# args are the roslaunch files to load
from . import parent as roslaunch_parent
try:
# force a port binding spec if we are running a core
if options.core:
options.port = options.port or DEFAULT_MASTER_PORT
p = roslaunch_parent.ROSLaunchParent(uuid, args, roslaunch_strs=roslaunch_strs,
is_core=options.core, port=options.port, local_only=options.local_only,
verbose=options.verbose, force_screen=options.force_screen,
num_workers=options.num_workers, timeout=options.timeout)
p.start()
p.spin()
finally:
# remove the pid file
if options.pid_fn:
try: os.unlink(options.pid_fn)
except os.error: pass
# force a port binding spec if we are running a core
if options.core:
options.port = options.port or DEFAULT_MASTER_PORT
p = roslaunch_parent.ROSLaunchParent(uuid, args, roslaunch_strs=roslaunch_strs,
is_core=options.core, port=options.port, local_only=options.local_only,
verbose=options.verbose, force_screen=options.force_screen,
num_workers=options.num_workers, timeout=options.timeout)
p.start()
p.spin()

except RLException as e:
roslaunch_core.printerrlog(str(e))
Expand All @@ -328,6 +322,12 @@ def main(argv=sys.argv):
except Exception as e:
traceback.print_exc()
sys.exit(1)
finally:
# remove the pid file
if options.pid_fn:
try: os.unlink(options.pid_fn)
except os.error: pass


if __name__ == '__main__':
main()

0 comments on commit d469733

Please sign in to comment.