File: case-22-empty-process-name.bash

package info (click to toggle)
lsof 4.99.4%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,924 kB
  • sloc: ansic: 50,680; sh: 8,351; makefile: 1,194; perl: 940; awk: 214
file content (31 lines) | stat: -rwxr-xr-x 798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# See https://github.com/lsof-org/lsof/issues/246
source tests/common.bash

{
    perl -e '$0 = ""; sleep 999' &
    pid=$!
    sleep 1

    output=$($lsof -w -ad cwd -F c -p "$pid")
    echo "lsof output:" >> $report
    echo "$output" >> $report
    kill $pid
    for entry in $output
    do
	if [[ $entry =~ ^p[0-9]+$ ]]; then
	    if [[ $entry != p$pid ]]; then
	        echo "Incorrect pid, expect p$pid, got $entry" >> $report
		exit 1
	    fi
	elif [[ $entry =~ c* ]]; then
	    if [[ $entry =~ cperl* ]]; then
	        echo "The platform does not report changed command name, that's okay" >> $report
	    elif [[ $entry != c ]]; then
	        echo "Process name should be empty, expect c, got $entry" >> $report
		exit 1
	    fi
	fi
    done
    exit 0
} > $report 2>&1