Menu

#30 PID is a CONST

trunk
closed-fixed
Aex Aey
PID (1)
5
2017-07-21
2017-07-04
spike
No

Hi!
In sources (pcapsipdump.cpp) I see that PID is a CONST, string №195:
const char *pid_file="/var/run/pcapsipdump.pid";
But for running two or more daemons (one daemon for one interface), PID must be a variable, getting from the command line arguments (debian/pcapsipdump.init):

PIDFILE="/var/run/pcapsipdump.pid"

start() {
        echo -n $"Starting $NAME: "
        start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
        start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
        return 0
}

Discussion

  • Aex Aey

    Aex Aey - 2017-07-21
    • status: open --> closed-fixed
    • assigned_to: Aex Aey
     
  • Aex Aey

    Aex Aey - 2017-07-21

    Added in [r131].

    Note that daemons self-forking is not the only and not the best way to fork. Some supervisors (inittab, systemd, djb's supervise) prefer supervisor to do the forking. This makes both pid discovery and wait(3) trivial. For example, from bash with any version of pcapsipdump:

    pcapsipdump -fi eth0 & echo $! >/var/run/pcapsipdump-eth0.pid
    pcapsipdump -fi eth1 & echo $! >/var/run/pcapsipdump-eth1.pid
    
     

    Related

    Commit: [r131]


Log in to post a comment.

MongoDB Logo MongoDB