Line | |
---|
1 | # From: John C. Oppenheimer <jco@slinky.convex.com>
|
---|
2 | # Subject: gawk-3.0.2 pid test
|
---|
3 | # To: arnold@skeeve.atl.ga.us
|
---|
4 | # Date: Mon, 10 Feb 1997 08:31:55 -0600 (CST)
|
---|
5 | #
|
---|
6 | # Thanks for the very quick reply.
|
---|
7 | #
|
---|
8 | # This all started when I was looking for how to do the equivalent of
|
---|
9 | # "nextfile." I was after documentation and found our gawk down a few
|
---|
10 | # revs.
|
---|
11 | #
|
---|
12 | # Looks like the nextfile functionality was added somewhere around
|
---|
13 | # 2.15.5. There wasn't a way to do it, until now! Thanks for the
|
---|
14 | # functionality!
|
---|
15 | #
|
---|
16 | # Saw the /dev/xxx capability and just tried it.
|
---|
17 | #
|
---|
18 | # Anyway, I wrote a pid test. I hope that it is portable. Wanted to
|
---|
19 | # make a user test, but looks like id(1) is not very portable. But a
|
---|
20 | # little test is better than none.
|
---|
21 | #
|
---|
22 | # John
|
---|
23 | #
|
---|
24 | # pid.ok is a zero length file
|
---|
25 | #
|
---|
26 | # ================== pid.awk ============
|
---|
27 | BEGIN {
|
---|
28 | getline pid <"/dev/pid"
|
---|
29 | getline ppid <"/dev/ppid"
|
---|
30 | }
|
---|
31 | NR == 1 {
|
---|
32 | if (pid != $0) {
|
---|
33 | printf "Bad pid %d, wanted %d\n", $0, pid
|
---|
34 | }
|
---|
35 | }
|
---|
36 | NR == 2 {
|
---|
37 | if (ppid != $0) {
|
---|
38 | printf "Bad ppid %d, wanted %d\n", $0, ppid
|
---|
39 | }
|
---|
40 | }
|
---|
41 | END { # ADR --- added
|
---|
42 | close("/dev/pid")
|
---|
43 | close("/dev/ppid")
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.