diff options
| author | Mistivia <i@mistivia.com> | 2025-11-02 15:29:28 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-02 15:29:28 +0800 |
| commit | 9f42c2d5f911cb4e215d7873221e642ce7df4d61 (patch) | |
| tree | 6dac90a889a7402a9556d3d1bcc5cb53cdb9f123 /ngircd/src/testsuite/getpid.sh | |
| parent | fb2d9de539b660a261af19b1cbcceb7ee7980cb1 (diff) | |
deprecate webircdateway and ngircd
Diffstat (limited to 'ngircd/src/testsuite/getpid.sh')
| -rwxr-xr-x | ngircd/src/testsuite/getpid.sh | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/ngircd/src/testsuite/getpid.sh b/ngircd/src/testsuite/getpid.sh deleted file mode 100755 index 7a3dbe3..0000000 --- a/ngircd/src/testsuite/getpid.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# ngIRCd Test Suite -# -# Try to detect the PID of a running process of the current user. -# - -set -u - -# did we get a name? -if [ $# -ne 1 ]; then - echo "Usage: $0 <name>" >&2 - exit 1 -fi - -UNAME=`uname` - -# Use pgrep(1) whenever possible -if [ -x /usr/bin/pgrep ]; then - case "$UNAME" in - "FreeBSD") - PGREP_FLAGS="-a" - ;; - *) - PGREP_FLAGS="" - esac - if [ -n "${LOGNAME:-}" ] || [ -n "${USER:-}" ]; then - # Try to narrow the search down to the current user ... - exec /usr/bin/pgrep $PGREP_FLAGS -n -u "${LOGNAME:-$USER}" "$1" - else - # ... but neither LOGNAME nor USER were set! - exec /usr/bin/pgrep $PGREP_FLAGS -n "$1" - fi -fi - -# pidof(1) could be a good alternative on elder Linux systems -if [ -x /bin/pidof ]; then - exec /bin/pidof -s "$1" -fi - -# fall back to ps(1) and parse its output: -# detect flags for "ps" and "head" -PS_PIDCOL=1 -case "$UNAME" in - "A/UX"|"GNU"|"SunOS") - PS_FLAGS="-a"; PS_PIDCOL=2 - ;; - "Haiku") - PS_FLAGS="-o Id -o Team" - ;; - *) - # Linux (GNU coreutils), Free/Net/OpenBSD, ... - PS_FLAGS="-o pid,comm" -esac - -# search PID -ps $PS_FLAGS >procs.tmp -grep -v "$$" procs.tmp | grep "$1" | \ - awk "{print \$$PS_PIDCOL}" | \ - sort -nr >pids.tmp -pid=`head -1 pids.tmp` -rm -rf procs.tmp pids.tmp - -# validate PID -[ "$pid" -gt 1 ] >/dev/null 2>&1 || exit 1 - -echo $pid -exit 0 |
