Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generic SIGINT parameter in kill command for gazebo script (melodic-devel) #724

Merged
merged 2 commits into from
May 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions gazebo_ros/scripts/gazebo
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ SCRIPT_DIR=$(dirname ${SCRIPT_DIR})
final="$@"

EXT=so
SIGNAL=SIGINT
if [ $(uname) = "Darwin" ]; then
EXT=dylib
SIGNAL=INT
fi

# add ros path plugin if it does not already exist in the passed in arguments
Expand Down Expand Up @@ -43,8 +41,15 @@ fi
final=$(relocate_remappings "${final}")

# Combine the commands
GAZEBO_MASTER_URI="$desired_master_uri" GAZEBO_MODEL_DATABASE_URI="$desired_model_database_uri" gzserver $final &
GAZEBO_MASTER_URI="$desired_master_uri" GAZEBO_MODEL_DATABASE_URI="$desired_model_database_uri" gzclient $client_final
GAZEBO_MASTER_URI="$desired_master_uri" GAZEBO_MODEL_DATABASE_URI="$desired_model_database_uri" gzserver $final &
gzserver_pid="$!"
# Use kill -0 to check if the process is running
if $(kill -0 $! 2> /dev/null); then
GAZEBO_MASTER_URI="$desired_master_uri" GAZEBO_MODEL_DATABASE_URI="$desired_model_database_uri" gzclient $client_final
fi

# Kill the server
kill -s $SIGNAL $!
# Kill the server if it is alive
if $(kill -0 $! 2> /dev/null); then
# -2 SIGINT valid for Linux and Mac
kill -2 $!
fi