Tiny Core Extensions > TCE Q&A Forum

lldpd not available for 16.x

<< < (5/6) > >>

orneh24:
Hey Rich,


--- Quote from: Rich on August 25, 2025, 09:03:55 PM ---..Please check if I finally got it right..

--- End quote ---
.. You did  :)


--- Code: ---root@box:/home/tc# ps -C lldpd
  PID TTY          TIME CMD
 1639 ?        00:00:00 lldpd
 1641 ?        00:00:00 lldpd
root@box:/home/tc# /usr/local/etc/init.d/lldpd status

lldpd is running.

root@box:/home/tc# /usr/local/etc/init.d/lldpd restart
root@box:/home/tc#
root@box:/home/tc# /usr/local/etc/init.d/lldpd status

lldpd is running.

root@box:/home/tc# ps -C lldpd
  PID TTY          TIME CMD
 1747 ?        00:00:00 lldpd
 1749 ?        00:00:00 lldpd
root@box:/home/tc#
--- End code ---

    [Edit]: Replaced quote tags with code tags.  Rich

patrikg:
Why not like another deamons SysV-init-skript rc files make a pid file with the pid number, and kill that number.
Something like this:

--- Code: ---#!/bin/sh
#
# Simple init script to start/stop a daemon with a PID file

DAEMON="/usr/local/bin/mydaemon"   # executable
PIDFILE="/var/run/mydaemon.pid"    # pid file
NAME="mydaemon"

start() {
    if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") 2>/dev/null; then
        echo "$NAME is already running"
        return 0
    fi
    echo "Starting $NAME..."
    $DAEMON &
    echo $! > "$PIDFILE"
    echo "$NAME started with PID $(cat $PIDFILE)"
}

stop() {
    if [ -f "$PIDFILE" ]; then
        PID=$(cat "$PIDFILE")
        if kill -0 "$PID" 2>/dev/null; then
            echo "Stopping $NAME..."
            kill "$PID"
            rm -f "$PIDFILE"
            echo "$NAME stopped"
        else
            echo "Process not running, removing stale PID file"
            rm -f "$PIDFILE"
        fi
    else
        echo "$NAME is not running"
    fi
}

status() {
    if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") 2>/dev/null; then
        echo "$NAME is running with PID $(cat $PIDFILE)"
        return 0
    else
        echo "$NAME is not running"
        return 1
    fi
}

restart() {
    stop
    sleep 1
    start
}

case "$1" in
    start) start ;;
    stop) stop ;;
    restart) restart ;;
    status) status ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac

exit 0

--- End code ---

Rich:
Hi patrikg

--- Quote from: patrikg on August 26, 2025, 01:42:05 AM ---Why not like another deamons SysV-init-skript rc files make a pid file with the pid number, ...
--- End quote ---
Here's what happens when you background lldpd:

--- Code: ---tc@box:~/lldpd$
tc@box:~/lldpd$
tc@box:~/lldpd$
tc@box:~/lldpd$ sudo /usr/local/sbin/lldpd &
tc@box:~/lldpd$
[1]+  Done                       sudo /usr/local/sbin/lldpd
tc@box:~/lldpd$ echo $!
5186
tc@box:~/lldpd$ ps aux | grep -v "grep" | grep /usr/local/sbin/lldpd
 5187 _lldpd   /usr/local/sbin/lldpd
 5189 _lldpd   /usr/local/sbin/lldpd
tc@box:~/lldpd$
--- End code ---
It launches 2 instances of itself and exits. The PID you get back is
for the original instance you launched, which already exited.

Also, lldpd creates its own PID file:

--- Code: ---tc@box:~/lldpd$ cat /var/run/lldpd.pid
5187
tc@box:~/lldpd$
--- End code ---


--- Quote --- ... and kill that number. ...
--- End quote ---
start-stop-daemon stop  sends kill signals to all copies of lldpd, regardless
of how many copies are currently running.

patrikg:
Ohh it's forking it self to two, didn't see that, sorry.

But if it's making it's own pid file it's should be the one you need, or am wrong ?
Should it be two pid numbers in that file ?

Or can you just kill the main process to kill the child.(sorry for this type of language)

Rich:
Hi patrikg

--- Quote from: patrikg on August 26, 2025, 03:24:45 PM --- ... Or can you just kill the main process to kill the child.(sorry for this type of language)
--- End quote ---
In a perfect world, yes. But if something goes wrong, it's probably
safer to send kill signals to all instances.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version