Sindbad~EG File Manager

Current Path : /usr/home/beeson/MathXpert/bin/
Upload File :
Current File : /usr/home/beeson/MathXpert/bin/killEngine.sh

#!/bin/sh

# Define Engine port
ENGINE_PORT=12349

echo "Stopping any existing MathXpertEngine processes on port $ENGINE_PORT..."

# Find and kill processes using the port
PIDS=$(sockstat -4 -l | awk -v port=$ENGINE_PORT '$6 ~ port {print $3}')  # Correct field for FreeBSD
if [ -n "$PIDS" ]; then
    echo "Killing processes: $PIDS"
    sudo kill -9 $PIDS
    sleep 2  # Give time for processes to terminate
else
    echo "No running processes found on port $ENGINE_PORT."
fi

# Verify if process is truly stopped
if sockstat -4 -l | grep -q ":$ENGINE_PORT"; then
    echo "Error: MathXpertEngine is still running. Try manually killing it."
    exit 1
else
    echo "MathXpertEngine successfully stopped."
fi

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists