home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
You can browse this item here: psmon
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
100%
| dexvert
| Internet Message Format (text/imf)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| C source text
| default
| |
99%
| file
| makefile script text
| default
| |
98%
| file
| C source, ASCII text
| default
| |
100%
| TrID
| E-Mail message (Var. 2)
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| application/mbox
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 6d 69 70 | 6f 73 33 21 69 6e 74 65 |From mip|os3!inte|
|00000010| 6c 63 61 21 6f 6c 69 76 | 65 62 21 61 6d 65 73 21 |lca!oliv|eb!ames!|
|00000020| 68 75 73 63 36 21 6e 65 | 63 6e 74 63 21 6e 63 6f |husc6!ne|cntc!nco|
|00000030| 61 73 74 21 61 6c 6c 62 | 65 72 79 20 53 61 74 20 |ast!allb|ery Sat |
|00000040| 4a 61 6e 20 32 33 20 31 | 39 3a 33 38 3a 32 31 20 |Jan 23 1|9:38:21 |
|00000050| 50 53 54 20 31 39 38 38 | 0a 41 72 74 69 63 6c 65 |PST 1988|.Article|
|00000060| 20 32 36 33 20 6f 66 20 | 63 6f 6d 70 2e 73 6f 75 | 263 of |comp.sou|
|00000070| 72 63 65 73 2e 6d 69 73 | 63 3a 0a 50 61 74 68 3a |rces.mis|c:.Path:|
|00000080| 20 74 64 32 63 61 64 21 | 6d 69 70 6f 73 33 21 69 | td2cad!|mipos3!i|
|00000090| 6e 74 65 6c 63 61 21 6f | 6c 69 76 65 62 21 61 6d |ntelca!o|liveb!am|
|000000a0| 65 73 21 68 75 73 63 36 | 21 6e 65 63 6e 74 63 21 |es!husc6|!necntc!|
|000000b0| 6e 63 6f 61 73 74 21 61 | 6c 6c 62 65 72 79 0a 46 |ncoast!a|llbery.F|
|000000c0| 72 6f 6d 3a 20 6d 6f 73 | 73 40 70 74 73 66 61 2e |rom: mos|s@ptsfa.|
|000000d0| 55 55 43 50 0a 4e 65 77 | 73 67 72 6f 75 70 73 3a |UUCP.New|sgroups:|
|000000e0| 20 63 6f 6d 70 2e 73 6f | 75 72 63 65 73 2e 6d 69 | comp.so|urces.mi|
|000000f0| 73 63 0a 53 75 62 6a 65 | 63 74 3a 20 76 30 32 69 |sc.Subje|ct: v02i|
|00000100| 30 31 34 3a 20 70 73 6d | 6f 6e 20 2d 20 6d 6f 6e |014: psm|on - mon|
|00000110| 69 74 6f 72 20 65 72 72 | 6f 72 20 6d 65 73 73 61 |itor err|or messa|
|00000120| 67 65 73 20 66 72 6f 6d | 20 70 6f 73 74 73 63 72 |ges from| postscr|
|00000130| 69 70 74 20 70 72 69 6e | 74 65 72 73 0a 4b 65 79 |ipt prin|ters.Key|
|00000140| 77 6f 72 64 73 3a 20 70 | 6f 73 74 73 63 72 69 70 |words: p|ostscrip|
|00000150| 74 20 65 72 72 6f 72 20 | 6d 65 73 73 61 67 65 73 |t error |messages|
|00000160| 0a 4d 65 73 73 61 67 65 | 2d 49 44 3a 20 3c 37 31 |.Message|-ID: <71|
|00000170| 30 37 40 6e 63 6f 61 73 | 74 2e 55 55 43 50 3e 0a |07@ncoas|t.UUCP>.|
|00000180| 44 61 74 65 3a 20 32 30 | 20 4a 61 6e 20 38 38 20 |Date: 20| Jan 88 |
|00000190| 30 31 3a 31 39 3a 30 33 | 20 47 4d 54 0a 53 65 6e |01:19:03| GMT.Sen|
|000001a0| 64 65 72 3a 20 61 6c 6c | 62 65 72 79 40 6e 63 6f |der: all|bery@nco|
|000001b0| 61 73 74 2e 55 55 43 50 | 0a 4c 69 6e 65 73 3a 20 |ast.UUCP|.Lines: |
|000001c0| 32 38 37 0a 41 70 70 72 | 6f 76 65 64 3a 20 61 6c |287.Appr|oved: al|
|000001d0| 6c 62 65 72 79 40 6e 63 | 6f 61 73 74 2e 55 55 43 |lbery@nc|oast.UUC|
|000001e0| 50 0a 58 2d 41 72 63 68 | 69 76 65 3a 20 63 6f 6d |P.X-Arch|ive: com|
|000001f0| 70 2e 73 6f 75 72 63 65 | 73 2e 6d 69 73 63 2f 38 |p.source|s.misc/8|
|00000200| 38 30 31 2f 31 34 0a 43 | 6f 6d 70 2e 73 6f 75 72 |801/14.C|omp.sour|
|00000210| 63 65 73 2e 6d 69 73 63 | 3a 20 56 6f 6c 75 6d 65 |ces.misc|: Volume|
|00000220| 20 32 2c 20 49 73 73 75 | 65 20 31 34 0a 53 75 62 | 2, Issu|e 14.Sub|
|00000230| 6d 69 74 74 65 64 2d 42 | 79 3a 20 3c 6d 6f 73 73 |mitted-B|y: <moss|
|00000240| 40 70 74 73 66 61 2e 55 | 55 43 50 3e 0a 41 72 63 |@ptsfa.U|UCP>.Arc|
|00000250| 68 69 76 65 2d 4e 61 6d | 65 3a 20 70 73 6d 6f 6e |hive-Nam|e: psmon|
|00000260| 0a 0a 43 6f 6d 70 2e 73 | 6f 75 72 63 65 73 2e 6d |..Comp.s|ources.m|
|00000270| 69 73 63 3a 20 56 6f 6c | 75 6d 65 20 32 2c 20 49 |isc: Vol|ume 2, I|
|00000280| 73 73 75 65 20 31 34 0a | 53 75 62 6d 69 74 74 65 |ssue 14.|Submitte|
|00000290| 64 2d 42 79 3a 20 3c 6d | 6f 73 73 40 70 74 73 66 |d-By: <m|oss@ptsf|
|000002a0| 61 2e 55 55 43 50 3e 0a | 41 72 63 68 69 76 65 2d |a.UUCP>.|Archive-|
|000002b0| 4e 61 6d 65 3a 20 70 73 | 6d 6f 6e 0a 0a 5b 54 68 |Name: ps|mon..[Th|
|000002c0| 65 20 6f 6e 6c 79 20 42 | 53 44 20 70 6f 72 74 69 |e only B|SD porti|
|000002d0| 6e 67 20 6e 65 65 64 65 | 64 20 73 68 6f 75 6c 64 |ng neede|d should|
|000002e0| 20 62 65 20 74 65 72 6d | 69 6f 2d 72 65 6c 61 74 | be term|io-relat|
|000002f0| 69 76 65 20 73 74 75 66 | 66 2e 20 20 2b 2b 62 73 |ive stuf|f. ++bs|
|00000300| 61 5d 0a 0a 48 65 72 65 | 27 73 20 61 20 73 75 62 |a]..Here|'s a sub|
|00000310| 6d 69 73 73 69 6f 6e 20 | 66 6f 72 20 61 20 73 69 |mission |for a si|
|00000320| 6d 70 6c 65 20 6d 6f 6e | 69 74 6f 72 20 70 72 6f |mple mon|itor pro|
|00000330| 67 72 61 6d 20 66 6f 72 | 20 50 6f 73 74 73 63 72 |gram for| Postscr|
|00000340| 69 70 74 20 0a 65 72 72 | 6f 72 20 6d 65 73 73 61 |ipt .err|or messa|
|00000350| 67 65 73 2e 20 49 74 20 | 77 61 73 20 77 72 69 74 |ges. It |was writ|
|00000360| 74 65 6e 20 66 6f 72 20 | 53 59 53 35 20 6c 69 6e |ten for |SYS5 lin|
|00000370| 65 20 70 72 69 6e 74 65 | 72 20 73 70 6f 6f 6c 69 |e printe|r spooli|
|00000380| 6e 67 2c 20 61 6e 64 0a | 77 72 69 74 65 73 20 70 |ng, and.|writes p|
|00000390| 72 69 6e 74 65 72 2d 64 | 65 74 65 63 74 65 64 20 |rinter-d|etected |
|000003a0| 65 72 72 6f 72 20 6d 65 | 73 73 61 67 65 73 20 69 |error me|ssages i|
|000003b0| 6e 74 6f 20 61 20 73 74 | 61 74 75 73 20 66 69 6c |nto a st|atus fil|
|000003c0| 65 2c 20 61 6c 6f 6e 67 | 0a 77 69 74 68 20 74 68 |e, along|.with th|
|000003d0| 65 20 75 73 65 72 27 73 | 20 6e 61 6d 65 20 61 6e |e user's| name an|
|000003e0| 64 20 6c 70 20 6a 6f 62 | 20 69 64 20 6e 75 6d 62 |d lp job| id numb|
|000003f0| 65 72 2e 0a 0a 4b 65 6e | 20 4b 65 69 72 6e 61 6e |er...Ken| Keirnan|
|00000400| 0a 0a 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |..------|--------|
|00000410| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000420| 63 75 74 20 68 65 72 65 | 2d 2d 2d 2d 2d 2d 2d 2d |cut here|--------|
|00000430| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000440| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 0a 23 21 20 2f 62 |--------|--.#! /b|
|00000450| 69 6e 2f 73 68 0a 23 20 | 54 68 69 73 20 69 73 20 |in/sh.# |This is |
|00000460| 61 20 73 68 65 6c 6c 20 | 61 72 63 68 69 76 65 2c |a shell |archive,|
|00000470| 20 6d 65 61 6e 69 6e 67 | 3a 0a 23 20 31 2e 20 52 | meaning|:.# 1. R|
|00000480| 65 6d 6f 76 65 20 65 76 | 65 72 79 74 68 69 6e 67 |emove ev|erything|
|00000490| 20 61 62 6f 76 65 20 74 | 68 65 20 23 21 20 2f 62 | above t|he #! /b|
|000004a0| 69 6e 2f 73 68 20 6c 69 | 6e 65 2e 0a 23 20 32 2e |in/sh li|ne..# 2.|
|000004b0| 20 53 61 76 65 20 74 68 | 65 20 72 65 73 75 6c 74 | Save th|e result|
|000004c0| 69 6e 67 20 74 65 78 74 | 20 69 6e 20 61 20 66 69 |ing text| in a fi|
|000004d0| 6c 65 2e 0a 23 20 33 2e | 20 45 78 65 63 75 74 65 |le..# 3.| Execute|
|000004e0| 20 74 68 65 20 66 69 6c | 65 20 77 69 74 68 20 2f | the fil|e with /|
|000004f0| 62 69 6e 2f 73 68 20 28 | 6e 6f 74 20 63 73 68 29 |bin/sh (|not csh)|
|00000500| 20 74 6f 20 63 72 65 61 | 74 65 20 74 68 65 20 66 | to crea|te the f|
|00000510| 69 6c 65 73 3a 0a 23 09 | 4d 61 6b 65 66 69 6c 65 |iles:.#.|Makefile|
|00000520| 0a 23 09 52 45 41 44 4d | 45 0a 23 09 70 73 2e 6d |.#.READM|E.#.ps.m|
|00000530| 6f 6e 69 74 6f 72 2e 63 | 0a 23 20 54 68 69 73 20 |onitor.c|.# This |
|00000540| 61 72 63 68 69 76 65 20 | 63 72 65 61 74 65 64 20 |archive |created |
|00000550| 62 79 20 4b 65 6e 20 4b | 65 69 72 6e 61 6e 2c 20 |by Ken K|eirnan, |
|00000560| 4d 6f 6e 20 4a 61 6e 20 | 31 38 20 30 39 3a 30 34 |Mon Jan |18 09:04|
|00000570| 3a 31 39 20 31 39 38 38 | 0a 65 78 70 6f 72 74 20 |:19 1988|.export |
|00000580| 50 41 54 48 3b 20 50 41 | 54 48 3d 2f 62 69 6e 3a |PATH; PA|TH=/bin:|
|00000590| 24 50 41 54 48 0a 69 66 | 20 74 65 73 74 20 2d 66 |$PATH.if| test -f|
|000005a0| 20 27 4d 61 6b 65 66 69 | 6c 65 27 0a 74 68 65 6e | 'Makefi|le'.then|
|000005b0| 0a 09 65 63 68 6f 20 73 | 68 61 72 3a 20 77 69 6c |..echo s|har: wil|
|000005c0| 6c 20 6e 6f 74 20 6f 76 | 65 72 2d 77 72 69 74 65 |l not ov|er-write|
|000005d0| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 22 | existin|g file "|
|000005e0| 27 4d 61 6b 65 66 69 6c | 65 27 22 0a 65 6c 73 65 |'Makefil|e'".else|
|000005f0| 0a 63 61 74 20 3c 3c 20 | 5c 53 48 41 52 5f 45 4f |.cat << |\SHAR_EO|
|00000600| 46 20 3e 20 27 4d 61 6b | 65 66 69 6c 65 27 0a 43 |F > 'Mak|efile'.C|
|00000610| 46 4c 41 47 53 20 3d 20 | 2d 4f 20 2d 73 0a 23 20 |FLAGS = |-O -s.# |
|00000620| 55 6e 63 6f 6d 6d 65 6e | 74 20 74 68 65 20 43 4c |Uncommen|t the CL|
|00000630| 49 42 20 6c 69 6e 65 20 | 69 66 20 79 6f 75 20 68 |IB line |if you h|
|00000640| 61 76 65 20 53 59 53 35 | 20 73 68 61 72 65 64 20 |ave SYS5| shared |
|00000650| 6c 69 62 72 61 72 69 65 | 73 0a 23 20 43 4c 49 42 |librarie|s.# CLIB|
|00000660| 20 3d 20 2d 6c 63 5f 73 | 0a 0a 61 6c 6c 3a 09 09 | = -lc_s|..all:..|
|00000670| 70 73 2e 6d 6f 6e 69 74 | 6f 72 0a 0a 70 73 2e 6d |ps.monit|or..ps.m|
|00000680| 6f 6e 69 74 6f 72 3a 09 | 70 73 2e 6d 6f 6e 69 74 |onitor:.|ps.monit|
|00000690| 6f 72 2e 63 0a 09 09 63 | 63 20 24 28 43 46 4c 41 |or.c...c|c $(CFLA|
|000006a0| 47 53 29 20 2d 6f 20 70 | 73 2e 6d 6f 6e 69 74 6f |GS) -o p|s.monito|
|000006b0| 72 20 70 73 2e 6d 6f 6e | 69 74 6f 72 2e 63 20 24 |r ps.mon|itor.c $|
|000006c0| 28 43 4c 49 42 29 0a 0a | 69 6e 73 74 61 6c 6c 3a |(CLIB)..|install:|
|000006d0| 09 61 6c 6c 0a 09 09 6d | 76 20 70 73 2e 6d 6f 6e |.all...m|v ps.mon|
|000006e0| 69 74 6f 72 20 2f 75 73 | 72 2f 6c 69 62 2f 70 73 |itor /us|r/lib/ps|
|000006f0| 2e 6d 6f 6e 69 74 6f 72 | 0a 09 09 63 68 6f 77 6e |.monitor|...chown|
|00000700| 20 6c 70 20 2f 75 73 72 | 2f 6c 69 62 2f 70 73 2e | lp /usr|/lib/ps.|
|00000710| 6d 6f 6e 69 74 6f 72 0a | 09 09 63 68 67 72 70 20 |monitor.|..chgrp |
|00000720| 73 79 73 20 2f 75 73 72 | 2f 6c 69 62 2f 70 73 2e |sys /usr|/lib/ps.|
|00000730| 6d 6f 6e 69 74 6f 72 0a | 09 09 63 68 6d 6f 64 20 |monitor.|..chmod |
|00000740| 34 37 35 35 20 2f 75 73 | 72 2f 6c 69 62 2f 70 73 |4755 /us|r/lib/ps|
|00000750| 2e 6d 6f 6e 69 74 6f 72 | 0a 53 48 41 52 5f 45 4f |.monitor|.SHAR_EO|
|00000760| 46 0a 63 68 6d 6f 64 20 | 2b 78 20 27 4d 61 6b 65 |F.chmod |+x 'Make|
|00000770| 66 69 6c 65 27 0a 66 69 | 20 23 20 65 6e 64 20 6f |file'.fi| # end o|
|00000780| 66 20 6f 76 65 72 77 72 | 69 74 69 6e 67 20 63 68 |f overwr|iting ch|
|00000790| 65 63 6b 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |eck.if t|est -f '|
|000007a0| 52 45 41 44 4d 45 27 0a | 74 68 65 6e 0a 09 65 63 |README'.|then..ec|
|000007b0| 68 6f 20 73 68 61 72 3a | 20 77 69 6c 6c 20 6e 6f |ho shar:| will no|
|000007c0| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|000007d0| 73 74 69 6e 67 20 66 69 | 6c 65 20 22 27 52 45 41 |sting fi|le "'REA|
|000007e0| 44 4d 45 27 22 0a 65 6c | 73 65 0a 63 61 74 20 3c |DME'".el|se.cat <|
|000007f0| 3c 20 5c 53 48 41 52 5f | 45 4f 46 20 3e 20 27 52 |< \SHAR_|EOF > 'R|
|00000800| 45 41 44 4d 45 27 0a 50 | 73 2e 6d 6f 6e 69 74 6f |EADME'.P|s.monito|
|00000810| 72 20 69 73 20 61 20 70 | 72 6f 67 72 61 6d 20 74 |r is a p|rogram t|
|00000820| 6f 20 6d 6f 6e 69 74 6f | 72 20 61 6e 64 20 6c 6f |o monito|r and lo|
|00000830| 67 20 69 6e 70 75 74 20 | 66 72 6f 6d 20 61 20 74 |g input |from a t|
|00000840| 74 79 20 6c 69 6e 65 20 | 63 6f 6e 6e 65 63 74 65 |ty line |connecte|
|00000850| 64 0a 74 6f 20 61 20 50 | 6f 73 74 53 63 72 69 70 |d.to a P|ostScrip|
|00000860| 74 20 70 72 69 6e 74 65 | 72 2e 20 20 49 74 20 63 |t printe|r. It c|
|00000870| 72 65 61 74 65 73 20 61 | 20 6c 6f 67 20 66 69 6c |reates a| log fil|
|00000880| 65 20 22 2f 75 73 72 2f | 73 70 6f 6f 6c 2f 6c 70 |e "/usr/|spool/lp|
|00000890| 2f 70 73 2e 65 72 72 6f | 72 22 0a 61 6e 64 20 61 |/ps.erro|r".and a|
|000008a0| 20 6c 6f 63 6b 20 66 69 | 6c 65 20 22 2f 75 73 72 | lock fi|le "/usr|
|000008b0| 2f 73 70 6f 6f 6c 2f 6c | 70 2f 50 53 5f 4c 4f 43 |/spool/l|p/PS_LOC|
|000008c0| 4b 22 20 74 6f 20 70 72 | 65 76 65 6e 74 20 6d 75 |K" to pr|event mu|
|000008d0| 6c 74 69 70 6c 65 20 69 | 6e 73 74 61 6e 63 65 73 |ltiple i|nstances|
|000008e0| 20 6f 66 0a 74 68 65 20 | 70 72 6f 67 72 61 6d 2e | of.the |program.|
|000008f0| 20 20 50 73 2e 6d 6f 6e | 69 74 6f 72 20 77 69 6c | Ps.mon|itor wil|
|00000900| 6c 20 63 6c 65 61 6e 20 | 75 70 20 74 68 65 20 6c |l clean |up the l|
|00000910| 6f 63 6b 20 66 69 6c 65 | 20 61 6e 64 20 73 74 6f |ock file| and sto|
|00000920| 70 20 6f 6e 20 61 20 53 | 49 47 54 45 52 4d 2e 0a |p on a S|IGTERM..|
|00000930| 57 68 65 6e 20 70 73 2e | 6d 6f 6e 69 74 6f 72 20 |When ps.|monitor |
|00000940| 73 74 61 72 74 73 2c 20 | 69 74 20 6d 6f 76 65 20 |starts, |it move |
|00000950| 61 6e 20 65 78 69 73 74 | 69 6e 67 20 22 70 73 2e |an exist|ing "ps.|
|00000960| 65 72 72 6f 72 22 20 66 | 69 6c 65 20 74 6f 20 22 |error" f|ile to "|
|00000970| 4f 70 73 2e 65 72 72 6f | 72 22 2c 0a 61 6e 64 20 |Ops.erro|r",.and |
|00000980| 77 72 69 74 65 73 20 74 | 68 65 20 64 61 74 65 20 |writes t|he date |
|00000990| 61 6e 64 20 74 69 6d 65 | 20 61 73 20 74 68 65 20 |and time| as the |
|000009a0| 66 69 72 73 74 20 6c 69 | 6e 65 20 69 6e 20 74 68 |first li|ne in th|
|000009b0| 65 20 6e 65 77 20 22 70 | 73 2e 65 72 72 6f 72 22 |e new "p|s.error"|
|000009c0| 20 66 69 6c 65 2e 0a 0a | 54 6f 20 6d 61 6b 65 20 | file...|To make |
|000009d0| 74 68 65 20 70 72 6f 67 | 72 61 6d 20 6a 75 73 74 |the prog|ram just|
|000009e0| 20 74 79 70 65 20 22 6d | 61 6b 65 22 2e 20 20 54 | type "m|ake". T|
|000009f0| 6f 20 6d 61 6b 65 20 74 | 68 65 20 70 72 6f 67 72 |o make t|he progr|
|00000a00| 61 6d 20 61 6e 64 20 69 | 6e 73 74 61 6c 6c 20 69 |am and i|nstall i|
|00000a10| 6e 0a 2f 75 73 72 2f 6c | 69 62 20 74 79 70 65 20 |n./usr/l|ib type |
|00000a20| 22 6d 61 6b 65 20 69 6e | 73 74 61 6c 6c 22 2e 0a |"make in|stall"..|
|00000a30| 0a 54 68 65 20 70 72 6f | 67 72 61 6d 20 69 73 20 |.The pro|gram is |
|00000a40| 6b 65 70 74 20 69 6e 20 | 2f 75 73 72 2f 6c 69 62 |kept in |/usr/lib|
|00000a50| 2f 70 73 2e 6d 6f 6e 69 | 74 6f 72 2c 20 61 6e 64 |/ps.moni|tor, and|
|00000a60| 20 69 73 20 63 61 6c 6c | 65 64 20 77 69 74 68 20 | is call|ed with |
|00000a70| 74 77 6f 20 61 72 67 75 | 6d 65 6e 74 73 2c 0a 74 |two argu|ments,.t|
|00000a80| 68 65 20 62 61 75 64 20 | 72 61 74 65 20 6f 66 20 |he baud |rate of |
|00000a90| 74 68 65 20 74 74 79 20 | 70 6f 72 74 2c 20 61 6e |the tty |port, an|
|00000aa0| 64 20 74 68 65 20 74 74 | 79 78 78 20 6e 61 6d 65 |d the tt|yxx name|
|00000ab0| 20 28 77 69 74 68 6f 75 | 74 20 74 68 65 20 22 2f | (withou|t the "/|
|00000ac0| 64 65 76 2f 22 29 20 61 | 73 20 69 6e 3a 0a 0a 09 |dev/") a|s in:...|
|00000ad0| 09 2f 75 73 72 2f 6c 69 | 62 2f 70 73 2e 6d 6f 6e |./usr/li|b/ps.mon|
|00000ae0| 69 74 6f 72 20 39 36 30 | 30 20 74 74 79 32 32 0a |itor 960|0 tty22.|
|00000af0| 0a 49 6e 20 74 68 65 20 | 73 79 73 74 65 6d 20 73 |.In the |system s|
|00000b00| 74 61 72 74 75 70 20 66 | 69 6c 65 73 20 6f 72 20 |tartup f|iles or |
|00000b10| 77 68 65 72 65 76 65 72 | 20 74 68 65 20 6c 69 6e |wherever| the lin|
|00000b20| 65 70 72 69 6e 74 65 72 | 20 73 74 61 72 74 75 70 |eprinter| startup|
|00000b30| 20 69 73 20 63 61 6c 6c | 65 64 0a 28 73 75 63 68 | is call|ed.(such|
|00000b40| 20 61 73 20 2f 65 74 63 | 2f 72 63 20 6f 72 20 2f | as /etc|/rc or /|
|00000b50| 65 74 63 2f 72 63 32 2e | 64 2c 20 65 74 63 2e 29 |etc/rc2.|d, etc.)|
|00000b60| 2c 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |, the fo|llowing |
|00000b70| 6c 69 6e 65 73 20 73 68 | 6f 75 6c 64 20 62 65 20 |lines sh|ould be |
|00000b80| 61 64 64 65 64 3a 0a 0a | 09 09 72 6d 20 2d 66 20 |added:..|..rm -f |
|00000b90| 2f 75 73 72 2f 73 70 6f | 6f 6c 2f 6c 70 2f 50 53 |/usr/spo|ol/lp/PS|
|00000ba0| 5f 4c 4f 43 4b 0a 09 09 | 2f 75 73 72 2f 6c 69 62 |_LOCK...|/usr/lib|
|00000bb0| 2f 70 73 2e 6d 6f 6e 69 | 74 6f 72 20 3c 62 61 75 |/ps.moni|tor <bau|
|00000bc0| 64 3e 20 3c 74 74 79 78 | 78 3e 0a 0a 77 68 65 72 |d> <ttyx|x>..wher|
|00000bd0| 65 20 3c 62 61 75 64 3e | 20 69 73 20 62 61 75 64 |e <baud>| is baud|
|00000be0| 20 72 61 74 65 20 6f 66 | 20 74 68 65 20 74 74 79 | rate of| the tty|
|00000bf0| 20 64 65 76 69 63 65 20 | 61 6e 64 20 3c 74 74 79 | device |and <tty|
|00000c00| 78 78 3e 20 69 73 20 74 | 68 65 20 74 74 79 20 6e |xx> is t|he tty n|
|00000c10| 61 6d 65 20 69 6e 0a 74 | 68 65 20 22 2f 64 65 76 |ame in.t|he "/dev|
|00000c20| 22 20 64 69 72 65 63 74 | 6f 72 79 2e 0a 0a 41 6c |" direct|ory...Al|
|00000c30| 73 6f 2c 20 69 66 20 74 | 68 65 20 70 72 69 6e 74 |so, if t|he print|
|00000c40| 65 72 20 64 72 69 76 65 | 72 20 6f 72 20 69 6e 74 |er drive|r or int|
|00000c50| 65 72 66 61 63 65 20 69 | 73 20 61 20 73 68 65 6c |erface i|s a shel|
|00000c60| 6c 20 70 72 6f 63 65 64 | 75 72 65 2c 20 61 20 6c |l proced|ure, a l|
|00000c70| 69 6e 65 0a 73 69 6d 69 | 6c 61 72 20 74 6f 20 74 |ine.simi|lar to t|
|00000c80| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 63 6f 75 |he follo|wing cou|
|00000c90| 6c 64 20 62 65 20 75 73 | 65 64 20 74 6f 20 6b 65 |ld be us|ed to ke|
|00000ca0| 65 70 20 74 72 61 63 6b | 20 6f 66 20 74 68 65 20 |ep track| of the |
|00000cb0| 75 73 65 72 2c 20 6a 6f | 62 20 69 64 0a 61 6e 64 |user, jo|b id.and|
|00000cc0| 20 74 69 6d 65 20 69 6e | 20 74 68 65 20 22 70 73 | time in| the "ps|
|00000cd0| 2e 65 72 72 6f 72 22 20 | 66 69 6c 65 3a 0a 0a 09 |.error" |file:...|
|00000ce0| 65 63 68 6f 20 22 3c 24 | 4a 4f 42 3e 2c 20 3c 24 |echo "<$|JOB>, <$|
|00000cf0| 55 53 45 52 3e 2c 20 60 | 2f 62 69 6e 2f 64 61 74 |USER>, `|/bin/dat|
|00000d00| 65 60 22 20 3e 3e 20 2f | 75 73 72 2f 73 70 6f 6f |e`" >> /|usr/spoo|
|00000d10| 6c 2f 6c 70 2f 70 73 2e | 65 72 72 6f 72 0a 0a 54 |l/lp/ps.|error..T|
|00000d20| 68 65 20 6c 6f 63 61 74 | 69 6f 6e 20 6f 66 20 74 |he locat|ion of t|
|00000d30| 68 65 20 6c 6f 63 6b 20 | 66 69 6c 65 20 61 6e 64 |he lock |file and|
|00000d40| 20 74 68 65 20 65 72 72 | 6f 72 20 6c 6f 67 20 63 | the err|or log c|
|00000d50| 61 6e 20 62 65 20 63 68 | 61 6e 67 65 64 20 62 79 |an be ch|anged by|
|00000d60| 20 6d 6f 64 69 66 79 69 | 6e 67 0a 74 68 65 20 64 | modifyi|ng.the d|
|00000d70| 65 66 69 6e 65 73 20 66 | 6f 72 20 4c 4f 43 4b 2c |efines f|or LOCK,|
|00000d80| 20 50 53 45 52 52 20 61 | 6e 64 20 4f 50 53 45 52 | PSERR a|nd OPSER|
|00000d90| 52 20 6e 65 61 72 20 74 | 68 65 20 62 65 67 69 6e |R near t|he begin|
|00000da0| 6e 69 6e 67 20 6f 66 20 | 74 68 65 20 70 72 6f 67 |ning of |the prog|
|00000db0| 72 61 6d 2c 0a 61 6e 64 | 20 74 68 65 20 64 69 72 |ram,.and| the dir|
|00000dc0| 65 63 74 6f 72 79 20 63 | 6f 6e 74 61 69 6e 69 6e |ectory c|ontainin|
|00000dd0| 67 20 74 68 65 20 70 72 | 6f 67 72 61 6d 20 63 61 |g the pr|ogram ca|
|00000de0| 6e 20 62 65 20 63 68 61 | 6e 67 65 64 20 69 6e 20 |n be cha|nged in |
|00000df0| 74 68 65 20 4d 61 6b 65 | 66 69 6c 65 2e 0a 0a 50 |the Make|file...P|
|00000e00| 72 65 63 61 75 74 69 6f | 6e 73 3a 0a 0a 54 68 65 |recautio|ns:..The|
|00000e10| 20 70 72 6f 67 72 61 6d | 20 77 61 73 20 69 6e 74 | program| was int|
|00000e20| 65 6e 64 65 64 20 66 6f | 72 20 53 59 53 35 20 6c |ended fo|r SYS5 l|
|00000e30| 69 6e 65 20 70 72 69 6e | 74 65 72 20 73 70 6f 6f |ine prin|ter spoo|
|00000e40| 6c 69 6e 67 20 73 79 73 | 74 65 6d 73 2c 20 61 6e |ling sys|tems, an|
|00000e50| 64 20 6d 61 79 0a 72 65 | 71 75 69 72 65 20 6d 6f |d may.re|quire mo|
|00000e60| 64 69 66 69 63 61 74 69 | 6f 6e 73 20 66 6f 72 20 |dificati|ons for |
|00000e70| 75 73 65 20 6f 6e 20 6f | 74 68 65 72 20 66 6c 61 |use on o|ther fla|
|00000e80| 76 6f 72 73 20 6f 66 20 | 55 6e 69 63 65 73 2e 2e |vors of |Unices..|
|00000e90| 2e 2e 2e 0a 0a 0a 09 09 | 09 09 09 4b 65 6e 20 4b |........|...Ken K|
|00000ea0| 65 69 72 6e 61 6e 0a 09 | 09 09 09 09 50 61 63 69 |eirnan..|....Paci|
|00000eb0| 66 69 63 20 5b 2a 5d 20 | 42 65 6c 6c 0a 09 09 09 |fic [*] |Bell....|
|00000ec0| 09 09 4d 69 6e 69 63 6f | 6d 70 75 74 65 72 20 4f |..Minico|mputer O|
|00000ed0| 70 65 72 61 74 69 6f 6e | 73 20 53 75 70 70 6f 72 |peration|s Suppor|
|00000ee0| 74 20 53 74 61 66 66 0a | 09 09 09 09 09 53 61 6e |t Staff.|.....San|
|00000ef0| 20 52 61 6d 6f 6e 2c 20 | 43 41 2e 20 20 39 34 35 | Ramon, |CA. 945|
|00000f00| 38 33 0a 09 09 09 09 09 | 28 34 31 35 29 20 38 32 |83......|(415) 82|
|00000f10| 33 2d 33 39 31 31 0a 09 | 09 09 09 09 7b 61 6d 65 |3-3911..|....{ame|
|00000f20| 73 2c 70 79 72 61 6d 69 | 64 2c 73 75 6e 7d 21 70 |s,pyrami|d,sun}!p|
|00000f30| 61 63 62 65 6c 6c 21 70 | 74 30 36 61 21 6b 6b 31 |acbell!p|t06a!kk1|
|00000f40| 0a 09 09 09 6f 72 09 09 | 7b 61 6d 65 73 2c 70 79 |....or..|{ames,py|
|00000f50| 72 61 6d 69 64 2c 73 75 | 6e 7d 21 70 74 73 66 61 |ramid,su|n}!ptsfa|
|00000f60| 21 70 74 30 36 61 21 6b | 6b 31 0a 53 48 41 52 5f |!pt06a!k|k1.SHAR_|
|00000f70| 45 4f 46 0a 63 68 6d 6f | 64 20 2b 78 20 27 52 45 |EOF.chmo|d +x 'RE|
|00000f80| 41 44 4d 45 27 0a 66 69 | 20 23 20 65 6e 64 20 6f |ADME'.fi| # end o|
|00000f90| 66 20 6f 76 65 72 77 72 | 69 74 69 6e 67 20 63 68 |f overwr|iting ch|
|00000fa0| 65 63 6b 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |eck.if t|est -f '|
|00000fb0| 70 73 2e 6d 6f 6e 69 74 | 6f 72 2e 63 27 0a 74 68 |ps.monit|or.c'.th|
|00000fc0| 65 6e 0a 09 65 63 68 6f | 20 73 68 61 72 3a 20 77 |en..echo| shar: w|
|00000fd0| 69 6c 6c 20 6e 6f 74 20 | 6f 76 65 72 2d 77 72 69 |ill not |over-wri|
|00000fe0| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|00000ff0| 20 22 27 70 73 2e 6d 6f | 6e 69 74 6f 72 2e 63 27 | "'ps.mo|nitor.c'|
|00001000| 22 0a 65 6c 73 65 0a 63 | 61 74 20 3c 3c 20 5c 53 |".else.c|at << \S|
|00001010| 48 41 52 5f 45 4f 46 20 | 3e 20 27 70 73 2e 6d 6f |HAR_EOF |> 'ps.mo|
|00001020| 6e 69 74 6f 72 2e 63 27 | 0a 2f 2a 0a 20 2a 20 70 |nitor.c'|./*. * p|
|00001030| 73 2e 6d 6f 6e 69 74 6f | 72 20 2d 20 6c 6f 67 20 |s.monito|r - log |
|00001040| 6f 75 74 70 75 74 20 66 | 72 6f 6d 20 50 6f 73 74 |output f|rom Post|
|00001050| 53 63 72 69 70 74 20 70 | 72 69 6e 74 65 72 0a 20 |Script p|rinter. |
|00001060| 2a 0a 20 2a 09 54 68 69 | 73 20 70 72 6f 67 72 61 |*. *.Thi|s progra|
|00001070| 6d 20 77 69 6c 6c 20 6d | 6f 6e 69 74 6f 72 20 61 |m will m|onitor a|
|00001080| 20 74 74 79 20 70 6f 72 | 74 20 66 6f 72 20 65 72 | tty por|t for er|
|00001090| 72 6f 72 2f 64 69 61 67 | 6e 6f 73 74 69 63 20 6d |ror/diag|nostic m|
|000010a0| 65 73 73 61 67 65 73 0a | 20 2a 09 66 72 6f 6d 20 |essages.| *.from |
|000010b0| 61 20 50 6f 73 74 53 63 | 72 69 70 74 20 70 72 69 |a PostSc|ript pri|
|000010c0| 6e 74 65 72 2c 20 61 6e | 64 20 6c 6f 67 20 74 68 |nter, an|d log th|
|000010d0| 65 6d 20 69 6e 20 2f 75 | 73 72 2f 73 70 6f 6f 6c |em in /u|sr/spool|
|000010e0| 2f 6c 70 2f 70 73 2e 65 | 72 72 6f 72 2e 0a 20 2a |/lp/ps.e|rror.. *|
|000010f0| 09 54 68 65 20 70 72 6f | 67 72 61 6d 20 72 75 6e |.The pro|gram run|
|00001100| 73 20 61 73 20 61 20 64 | 61 65 6d 6f 6e 20 28 70 |s as a d|aemon (p|
|00001110| 6c 61 63 65 73 20 69 74 | 73 65 6c 66 20 69 6e 20 |laces it|self in |
|00001120| 74 68 65 20 62 61 63 6b | 67 72 6f 75 6e 64 20 61 |the back|ground a|
|00001130| 6e 64 0a 20 2a 09 69 67 | 6e 6f 72 65 73 20 6d 6f |nd. *.ig|nores mo|
|00001140| 73 74 20 69 6e 74 65 72 | 72 75 70 74 73 29 2c 20 |st inter|rupts), |
|00001150| 61 6e 64 20 77 69 6c 6c | 20 73 74 6f 70 20 63 6c |and will| stop cl|
|00001160| 65 61 6e 6c 79 20 6f 6e | 20 53 49 47 54 45 52 4d |eanly on| SIGTERM|
|00001170| 2e 20 20 41 20 6c 6f 63 | 6b 0a 20 2a 09 66 69 6c |. A loc|k. *.fil|
|00001180| 65 20 28 2f 75 73 72 2f | 73 70 6f 6f 6c 2f 6c 70 |e (/usr/|spool/lp|
|00001190| 2f 50 53 5f 4c 4f 43 4b | 29 20 69 73 20 63 72 65 |/PS_LOCK|) is cre|
|000011a0| 61 74 65 64 20 74 6f 20 | 70 72 65 76 65 6e 74 20 |ated to |prevent |
|000011b0| 6d 75 6c 74 69 70 6c 65 | 20 69 6e 73 74 61 6e 63 |multiple| instanc|
|000011c0| 65 73 0a 20 2a 09 6f 66 | 20 74 68 65 20 70 72 6f |es. *.of| the pro|
|000011d0| 67 72 61 6d 2c 20 61 6e | 64 20 74 68 65 20 6c 6f |gram, an|d the lo|
|000011e0| 63 6b 20 6d 61 79 20 68 | 61 76 65 20 74 6f 20 62 |ck may h|ave to b|
|000011f0| 65 20 72 65 6d 6f 76 65 | 64 20 6d 61 6e 75 61 6c |e remove|d manual|
|00001200| 6c 79 20 69 66 20 74 68 | 65 0a 20 2a 09 70 72 6f |ly if th|e. *.pro|
|00001210| 67 72 61 6d 20 69 73 20 | 73 74 6f 70 70 65 64 20 |gram is |stopped |
|00001220| 77 69 74 68 20 6f 74 68 | 65 72 20 74 68 61 6e 20 |with oth|er than |
|00001230| 53 49 47 54 45 52 4d 2e | 0a 20 2a 0a 20 2a 09 54 |SIGTERM.|. *. *.T|
|00001240| 6f 20 63 6f 6d 70 69 6c | 65 3a 09 63 63 20 2d 4f |o compil|e:.cc -O|
|00001250| 20 2d 73 20 2d 6f 20 2f | 75 73 72 2f 6c 69 62 2f | -s -o /|usr/lib/|
|00001260| 70 73 2e 6d 6f 6e 69 74 | 6f 72 20 70 73 2e 6d 6f |ps.monit|or ps.mo|
|00001270| 6e 69 74 6f 72 2e 63 0a | 20 2a 09 09 09 63 68 6f |nitor.c.| *...cho|
|00001280| 77 6e 20 6c 70 20 2f 75 | 73 72 2f 6c 69 62 2f 70 |wn lp /u|sr/lib/p|
|00001290| 73 2e 6d 6f 6e 69 74 6f | 72 0a 20 2a 09 09 09 63 |s.monito|r. *...c|
|000012a0| 68 6d 6f 64 20 34 37 35 | 35 20 2f 75 73 72 2f 6c |hmod 475|5 /usr/l|
|000012b0| 69 62 2f 70 73 2e 6d 6f | 6e 69 74 6f 72 0a 20 2a |ib/ps.mo|nitor. *|
|000012c0| 0a 20 2a 09 55 73 61 67 | 65 3a 09 09 2f 75 73 72 |. *.Usag|e:../usr|
|000012d0| 2f 6c 69 62 2f 70 73 2e | 6d 6f 6e 69 74 6f 72 20 |/lib/ps.|monitor |
|000012e0| 3c 62 61 75 64 3e 20 3c | 74 74 79 78 78 3e 0a 20 |<baud> <|ttyxx>. |
|000012f0| 2a 2f 0a 23 69 6e 63 6c | 75 64 65 20 3c 66 63 6e |*/.#incl|ude <fcn|
|00001300| 74 6c 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |tl.h>.#i|nclude <|
|00001310| 73 69 67 6e 61 6c 2e 68 | 3e 0a 23 69 6e 63 6c 75 |signal.h|>.#inclu|
|00001320| 64 65 20 3c 73 74 64 69 | 6f 2e 68 3e 0a 23 69 6e |de <stdi|o.h>.#in|
|00001330| 63 6c 75 64 65 20 3c 74 | 65 72 6d 69 6f 2e 68 3e |clude <t|ermio.h>|
|00001340| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 74 69 6d 65 2e |.#includ|e <time.|
|00001350| 68 3e 0a 0a 23 64 65 66 | 69 6e 65 09 4c 4f 43 4b |h>..#def|ine.LOCK|
|00001360| 09 22 2f 75 73 72 2f 73 | 70 6f 6f 6c 2f 6c 70 2f |."/usr/s|pool/lp/|
|00001370| 50 53 5f 4c 4f 43 4b 22 | 0a 23 64 65 66 69 6e 65 |PS_LOCK"|.#define|
|00001380| 20 50 53 45 52 52 09 22 | 2f 75 73 72 2f 73 70 6f | PSERR."|/usr/spo|
|00001390| 6f 6c 2f 6c 70 2f 70 73 | 2e 65 72 72 6f 72 22 0a |ol/lp/ps|.error".|
|000013a0| 23 64 65 66 69 6e 65 20 | 4f 50 53 45 52 52 09 22 |#define |OPSERR."|
|000013b0| 2f 75 73 72 2f 73 70 6f | 6f 6c 2f 6c 70 2f 4f 70 |/usr/spo|ol/lp/Op|
|000013c0| 73 2e 65 72 72 6f 72 22 | 0a 23 64 65 66 69 6e 65 |s.error"|.#define|
|000013d0| 20 46 50 52 09 28 76 6f | 69 64 29 66 70 72 69 6e | FPR.(vo|id)fprin|
|000013e0| 74 66 0a 0a 76 6f 69 64 | 20 65 78 69 74 28 29 3b |tf..void| exit();|
|000013f0| 0a 76 6f 69 64 20 73 70 | 69 6e 6f 66 66 28 29 3b |.void sp|inoff();|
|00001400| 0a 69 6e 74 20 75 6e 6c | 6f 63 6b 28 29 3b 0a 0a |.int unl|ock();..|
|00001410| 6d 61 69 6e 28 61 72 67 | 63 2c 20 61 72 67 76 29 |main(arg|c, argv)|
|00001420| 0a 69 6e 74 20 61 72 67 | 63 3b 0a 63 68 61 72 20 |.int arg|c;.char |
|00001430| 2a 2a 61 72 67 76 3b 0a | 7b 0a 09 72 65 67 69 73 |**argv;.|{..regis|
|00001440| 74 65 72 20 46 49 4c 45 | 20 2a 6f 66 70 3b 0a 09 |ter FILE| *ofp;..|
|00001450| 72 65 67 69 73 74 65 72 | 20 69 2c 20 70 73 66 64 |register| i, psfd|
|00001460| 3b 0a 09 63 68 61 72 20 | 6c 62 75 66 5b 35 31 32 |;..char |lbuf[512|
|00001470| 5d 3b 0a 09 63 68 61 72 | 20 64 62 75 66 5b 36 34 |];..char| dbuf[64|
|00001480| 5d 3b 0a 09 6c 6f 6e 67 | 20 74 2c 20 74 69 6d 65 |];..long| t, time|
|00001490| 28 29 3b 0a 0a 09 28 76 | 6f 69 64 29 75 6d 61 73 |();...(v|oid)umas|
|000014a0| 6b 28 30 29 3b 0a 0a 09 | 69 66 20 28 61 72 67 63 |k(0);...|if (argc|
|000014b0| 20 21 3d 20 33 29 20 7b | 0a 09 09 46 50 52 28 73 | != 3) {|...FPR(s|
|000014c0| 74 64 65 72 72 2c 20 22 | 55 73 61 67 65 3a 20 70 |tderr, "|Usage: p|
|000014d0| 73 2e 6d 6f 6e 69 74 6f | 72 20 3c 62 61 75 64 3e |s.monito|r <baud>|
|000014e0| 20 3c 74 74 79 78 78 3e | 5c 6e 22 29 3b 0a 09 09 | <ttyxx>|\n");...|
|000014f0| 65 78 69 74 28 31 29 3b | 0a 09 7d 0a 09 69 66 20 |exit(1);|..}..if |
|00001500| 28 61 63 63 65 73 73 28 | 4c 4f 43 4b 2c 20 30 29 |(access(|LOCK, 0)|
|00001510| 20 3d 3d 20 30 29 20 7b | 0a 09 09 46 50 52 28 73 | == 0) {|...FPR(s|
|00001520| 74 64 65 72 72 2c 20 22 | 70 73 2e 6d 6f 6e 69 74 |tderr, "|ps.monit|
|00001530| 6f 72 3a 20 61 6c 72 65 | 61 64 79 20 61 63 74 69 |or: alre|ady acti|
|00001540| 76 65 5c 6e 22 29 3b 0a | 09 09 46 50 52 28 73 74 |ve\n");.|..FPR(st|
|00001550| 64 65 72 72 2c 20 22 20 | 20 20 20 28 25 73 20 61 |derr, " | (%s a|
|00001560| 6c 72 65 61 64 79 20 65 | 78 69 73 74 73 29 5c 6e |lready e|xists)\n|
|00001570| 22 2c 20 4c 4f 43 4b 29 | 3b 0a 09 09 65 78 69 74 |", LOCK)|;...exit|
|00001580| 28 30 29 3b 0a 09 7d 0a | 09 69 20 3d 20 67 65 74 |(0);..}.|.i = get|
|00001590| 73 70 65 65 64 28 61 74 | 6f 69 28 61 72 67 76 5b |speed(at|oi(argv[|
|000015a0| 31 5d 29 29 3b 0a 0a 09 | 28 76 6f 69 64 29 73 70 |1]));...|(void)sp|
|000015b0| 72 69 6e 74 66 28 64 62 | 75 66 2c 20 22 2f 64 65 |rintf(db|uf, "/de|
|000015c0| 76 2f 25 73 22 2c 20 61 | 72 67 76 5b 32 5d 29 3b |v/%s", a|rgv[2]);|
|000015d0| 0a 0a 09 69 66 20 28 28 | 70 73 66 64 20 3d 20 6f |...if ((|psfd = o|
|000015e0| 70 65 6e 28 64 62 75 66 | 2c 20 4f 5f 52 44 4f 4e |pen(dbuf|, O_RDON|
|000015f0| 4c 59 29 29 20 3d 3d 20 | 2d 31 29 20 7b 0a 09 09 |LY)) == |-1) {...|
|00001600| 46 50 52 28 73 74 64 65 | 72 72 2c 20 22 70 73 2e |FPR(stde|rr, "ps.|
|00001610| 6d 6f 6e 69 74 6f 72 3a | 20 63 61 6e 27 74 20 6f |monitor:| can't o|
|00001620| 70 65 6e 20 25 73 5c 6e | 22 2c 20 64 62 75 66 29 |pen %s\n|", dbuf)|
|00001630| 3b 0a 09 09 65 78 69 74 | 28 31 29 3b 0a 09 7d 0a |;...exit|(1);..}.|
|00001640| 09 69 66 20 28 73 65 74 | 74 74 79 28 70 73 66 64 |.if (set|tty(psfd|
|00001650| 2c 20 69 29 20 3d 3d 20 | 2d 31 29 20 7b 0a 09 09 |, i) == |-1) {...|
|00001660| 46 50 52 28 73 74 64 65 | 72 72 2c 20 22 70 73 2e |FPR(stde|rr, "ps.|
|00001670| 6d 6f 6e 69 74 6f 72 3a | 20 69 6f 63 74 6c 20 66 |monitor:| ioctl f|
|00001680| 61 69 6c 65 64 20 6f 6e | 20 25 73 5c 6e 22 2c 20 |ailed on| %s\n", |
|00001690| 64 62 75 66 29 3b 0a 09 | 09 65 78 69 74 28 31 29 |dbuf);..|.exit(1)|
|000016a0| 3b 0a 09 7d 0a 0a 09 69 | 66 20 28 6c 69 6e 6b 28 |;..}...i|f (link(|
|000016b0| 50 53 45 52 52 2c 20 4f | 50 53 45 52 52 29 20 21 |PSERR, O|PSERR) !|
|000016c0| 3d 20 2d 31 29 0a 09 09 | 28 76 6f 69 64 29 75 6e |= -1)...|(void)un|
|000016d0| 6c 69 6e 6b 28 50 53 45 | 52 52 29 3b 0a 0a 09 69 |link(PSE|RR);...i|
|000016e0| 66 20 28 28 6f 66 70 20 | 3d 20 66 6f 70 65 6e 28 |f ((ofp |= fopen(|
|000016f0| 50 53 45 52 52 2c 20 22 | 61 22 29 29 20 3d 3d 20 |PSERR, "|a")) == |
|00001700| 4e 55 4c 4c 29 20 7b 0a | 09 09 46 50 52 28 73 74 |NULL) {.|..FPR(st|
|00001710| 64 65 72 72 2c 20 22 70 | 73 2e 6d 6f 6e 69 74 6f |derr, "p|s.monito|
|00001720| 72 3a 20 63 61 6e 27 74 | 20 63 72 65 61 74 65 20 |r: can't| create |
|00001730| 65 72 72 6f 72 20 6c 6f | 67 20 25 73 5c 6e 22 2c |error lo|g %s\n",|
|00001740| 20 50 53 45 52 52 29 3b | 0a 09 09 65 78 69 74 28 | PSERR);|...exit(|
|00001750| 31 29 3b 0a 09 7d 0a 0a | 09 73 70 69 6e 6f 66 66 |1);..}..|.spinoff|
|00001760| 28 29 3b 0a 0a 09 2f 2a | 0a 09 20 2a 20 49 67 6e |();.../*|.. * Ign|
|00001770| 6f 72 65 20 63 6f 6d 6d | 6f 6e 20 73 69 67 6e 61 |ore comm|on signa|
|00001780| 6c 73 0a 09 20 2a 2f 0a | 09 28 76 6f 69 64 29 73 |ls.. */.|.(void)s|
|00001790| 69 67 6e 61 6c 28 53 49 | 47 48 55 50 2c 20 53 49 |ignal(SI|GHUP, SI|
|000017a0| 47 5f 49 47 4e 29 3b 0a | 09 28 76 6f 69 64 29 73 |G_IGN);.|.(void)s|
|000017b0| 69 67 6e 61 6c 28 53 49 | 47 51 55 49 54 2c 20 53 |ignal(SI|GQUIT, S|
|000017c0| 49 47 5f 49 47 4e 29 3b | 0a 09 28 76 6f 69 64 29 |IG_IGN);|..(void)|
|000017d0| 73 69 67 6e 61 6c 28 53 | 49 47 49 4e 54 2c 20 53 |signal(S|IGINT, S|
|000017e0| 49 47 5f 49 47 4e 29 3b | 0a 09 28 76 6f 69 64 29 |IG_IGN);|..(void)|
|000017f0| 73 69 67 6e 61 6c 28 53 | 49 47 50 49 50 45 2c 20 |signal(S|IGPIPE, |
|00001800| 53 49 47 5f 49 47 4e 29 | 3b 0a 09 28 76 6f 69 64 |SIG_IGN)|;..(void|
|00001810| 29 73 69 67 6e 61 6c 28 | 53 49 47 41 4c 52 4d 2c |)signal(|SIGALRM,|
|00001820| 20 53 49 47 5f 49 47 4e | 29 3b 0a 09 28 76 6f 69 | SIG_IGN|);..(voi|
|00001830| 64 29 73 69 67 6e 61 6c | 28 53 49 47 54 45 52 4d |d)signal|(SIGTERM|
|00001840| 2c 20 75 6e 6c 6f 63 6b | 29 3b 0a 0a 09 74 20 3d |, unlock|);...t =|
|00001850| 20 74 69 6d 65 28 28 6c | 6f 6e 67 20 2a 29 30 29 | time((l|ong *)0)|
|00001860| 3b 0a 09 46 50 52 28 6f | 66 70 2c 20 22 43 72 65 |;..FPR(o|fp, "Cre|
|00001870| 61 74 65 64 3a 20 25 73 | 22 2c 20 63 74 69 6d 65 |ated: %s|", ctime|
|00001880| 28 26 74 29 29 3b 0a 09 | 28 76 6f 69 64 29 66 66 |(&t));..|(void)ff|
|00001890| 6c 75 73 68 28 6f 66 70 | 29 3b 0a 0a 09 77 68 69 |lush(ofp|);...whi|
|000018a0| 6c 65 20 28 28 69 20 3d | 20 72 65 61 64 28 70 73 |le ((i =| read(ps|
|000018b0| 66 64 2c 20 6c 62 75 66 | 2c 20 35 31 32 29 29 20 |fd, lbuf|, 512)) |
|000018c0| 3e 3d 20 30 29 0a 09 09 | 69 66 20 28 69 29 20 7b |>= 0)...|if (i) {|
|000018d0| 0a 09 09 09 28 76 6f 69 | 64 29 66 77 72 69 74 65 |....(voi|d)fwrite|
|000018e0| 28 6c 62 75 66 2c 20 31 | 2c 20 69 2c 20 6f 66 70 |(lbuf, 1|, i, ofp|
|000018f0| 29 3b 0a 09 09 09 28 76 | 6f 69 64 29 66 66 6c 75 |);....(v|oid)fflu|
|00001900| 73 68 28 6f 66 70 29 3b | 0a 09 09 7d 0a 0a 09 72 |sh(ofp);|...}...r|
|00001910| 65 74 75 72 6e 28 30 29 | 3b 0a 7d 0a 0a 67 65 74 |eturn(0)|;.}..get|
|00001920| 73 70 65 65 64 28 6e 29 | 0a 69 6e 74 20 6e 3b 0a |speed(n)|.int n;.|
|00001930| 7b 0a 09 73 77 69 74 63 | 68 20 28 6e 29 20 7b 0a |{..switc|h (n) {.|
|00001940| 0a 09 63 61 73 65 20 33 | 30 30 3a 0a 09 09 72 65 |..case 3|00:...re|
|00001950| 74 75 72 6e 28 42 33 30 | 30 29 3b 0a 09 63 61 73 |turn(B30|0);..cas|
|00001960| 65 20 31 32 30 30 3a 0a | 09 09 72 65 74 75 72 6e |e 1200:.|..return|
|00001970| 28 42 31 32 30 30 29 3b | 0a 09 63 61 73 65 20 32 |(B1200);|..case 2|
|00001980| 34 30 30 3a 0a 09 09 72 | 65 74 75 72 6e 28 42 32 |400:...r|eturn(B2|
|00001990| 34 30 30 29 3b 0a 09 63 | 61 73 65 20 34 38 30 30 |400);..c|ase 4800|
|000019a0| 3a 0a 09 09 72 65 74 75 | 72 6e 28 42 34 38 30 30 |:...retu|rn(B4800|
|000019b0| 29 3b 0a 09 63 61 73 65 | 20 39 36 30 30 3a 0a 09 |);..case| 9600:..|
|000019c0| 09 72 65 74 75 72 6e 28 | 42 39 36 30 30 29 3b 0a |.return(|B9600);.|
|000019d0| 09 63 61 73 65 20 31 39 | 32 30 30 3a 0a 09 09 72 |.case 19|200:...r|
|000019e0| 65 74 75 72 6e 28 42 31 | 39 32 30 30 29 3b 0a 09 |eturn(B1|9200);..|
|000019f0| 7d 0a 0a 09 72 65 74 75 | 72 6e 28 42 39 36 30 30 |}...retu|rn(B9600|
|00001a00| 29 3b 09 2f 2a 20 64 65 | 66 61 75 6c 74 20 66 6f |);./* de|fault fo|
|00001a10| 72 20 6e 6f 20 6d 61 74 | 63 68 20 39 36 30 30 20 |r no mat|ch 9600 |
|00001a20| 62 61 75 64 20 2a 2f 0a | 7d 0a 0a 2f 2a 0a 20 2a |baud */.|}../*. *|
|00001a30| 20 73 65 74 74 74 79 28 | 29 20 2d 20 73 65 74 20 | settty(|) - set |
|00001a40| 74 74 79 20 6d 6f 64 65 | 73 20 28 69 66 20 6f 75 |tty mode|s (if ou|
|00001a50| 74 70 75 74 20 63 6f 6e | 6e 65 63 74 65 64 20 74 |tput con|nected t|
|00001a60| 6f 20 61 20 74 74 79 29 | 2e 0a 20 2a 2f 0a 73 65 |o a tty)|.. */.se|
|00001a70| 74 74 74 79 28 66 64 2c | 20 73 70 65 65 64 29 0a |ttty(fd,| speed).|
|00001a80| 69 6e 74 20 66 64 2c 20 | 73 70 65 65 64 3b 0a 7b |int fd, |speed;.{|
|00001a90| 0a 09 73 74 72 75 63 74 | 20 74 65 72 6d 69 6f 20 |..struct| termio |
|00001aa0| 74 65 72 6d 62 75 66 66 | 3b 0a 0a 09 69 66 20 28 |termbuff|;...if (|
|00001ab0| 69 6f 63 74 6c 28 66 64 | 2c 20 54 43 47 45 54 41 |ioctl(fd|, TCGETA|
|00001ac0| 2c 20 26 74 65 72 6d 62 | 75 66 66 29 20 3d 3d 20 |, &termb|uff) == |
|00001ad0| 2d 31 29 0a 09 09 72 65 | 74 75 72 6e 28 2d 31 29 |-1)...re|turn(-1)|
|00001ae0| 3b 0a 09 2f 2a 0a 09 20 | 2a 20 45 6e 61 62 6c 65 |;../*.. |* Enable|
|00001af0| 20 43 61 6e 6f 6e 69 63 | 61 6c 2c 20 58 4f 4e 20 | Canonic|al, XON |
|00001b00| 2f 20 58 4f 46 46 20 66 | 6c 6f 77 20 63 6f 6e 74 |/ XOFF f|low cont|
|00001b10| 72 6f 6c 2c 20 61 6e 64 | 20 73 65 74 20 62 61 75 |rol, and| set bau|
|00001b20| 64 2e 0a 09 20 2a 2f 0a | 09 74 65 72 6d 62 75 66 |d... */.|.termbuf|
|00001b30| 66 2e 63 5f 6c 66 6c 61 | 67 20 3d 20 49 43 41 4e |f.c_lfla|g = ICAN|
|00001b40| 4f 4e 3b 0a 09 74 65 72 | 6d 62 75 66 66 2e 63 5f |ON;..ter|mbuff.c_|
|00001b50| 69 66 6c 61 67 20 3d 20 | 49 58 4f 4e 20 7c 20 49 |iflag = |IXON | I|
|00001b60| 58 4f 46 46 3b 0a 09 74 | 65 72 6d 62 75 66 66 2e |XOFF;..t|ermbuff.|
|00001b70| 63 5f 63 66 6c 61 67 20 | 3d 20 73 70 65 65 64 20 |c_cflag |= speed |
|00001b80| 7c 20 43 53 38 20 7c 20 | 43 52 45 41 44 3b 0a 09 || CS8 | |CREAD;..|
|00001b90| 74 65 72 6d 62 75 66 66 | 2e 63 5f 6f 66 6c 61 67 |termbuff|.c_oflag|
|00001ba0| 20 3d 20 30 3b 0a 0a 09 | 28 76 6f 69 64 29 69 6f | = 0;...|(void)io|
|00001bb0| 63 74 6c 28 66 64 2c 20 | 54 43 53 45 54 41 57 2c |ctl(fd, |TCSETAW,|
|00001bc0| 20 26 74 65 72 6d 62 75 | 66 66 29 3b 0a 0a 09 72 | &termbu|ff);...r|
|00001bd0| 65 74 75 72 6e 28 30 29 | 3b 0a 7d 0a 0a 76 6f 69 |eturn(0)|;.}..voi|
|00001be0| 64 0a 73 70 69 6e 6f 66 | 66 28 29 0a 7b 0a 09 72 |d.spinof|f().{..r|
|00001bf0| 65 67 69 73 74 65 72 20 | 46 49 4c 45 20 2a 66 70 |egister |FILE *fp|
|00001c00| 3b 0a 09 72 65 67 69 73 | 74 65 72 20 69 3b 0a 0a |;..regis|ter i;..|
|00001c10| 09 2f 2a 0a 09 20 2a 20 | 43 72 65 61 74 65 20 61 |./*.. * |Create a|
|00001c20| 20 63 68 69 6c 64 20 70 | 72 6f 63 65 73 73 0a 09 | child p|rocess..|
|00001c30| 20 2a 2f 0a 09 69 66 20 | 28 28 69 20 3d 20 66 6f | */..if |((i = fo|
|00001c40| 72 6b 28 29 29 20 3d 3d | 20 2d 31 29 20 7b 0a 09 |rk()) ==| -1) {..|
|00001c50| 09 46 50 52 28 73 74 64 | 65 72 72 2c 20 22 70 73 |.FPR(std|err, "ps|
|00001c60| 2e 6d 6f 6e 69 74 6f 72 | 3a 20 63 61 6e 27 74 20 |.monitor|: can't |
|00001c70| 66 6f 72 6b 28 29 5c 6e | 22 29 3b 0a 09 09 65 78 |fork()\n|");...ex|
|00001c80| 69 74 28 31 29 3b 0a 09 | 7d 0a 09 2f 2a 0a 09 20 |it(1);..|}../*.. |
|00001c90| 2a 20 54 68 65 20 70 61 | 72 65 6e 74 20 64 69 65 |* The pa|rent die|
|00001ca0| 73 20 6c 65 61 76 69 6e | 67 20 74 68 65 20 63 68 |s leavin|g the ch|
|00001cb0| 69 6c 64 20 69 6e 68 65 | 72 69 74 65 64 20 62 79 |ild inhe|rited by|
|00001cc0| 20 70 69 64 20 31 0a 09 | 20 2a 2f 0a 09 69 66 20 | pid 1..| */..if |
|00001cd0| 28 69 29 20 7b 0a 09 09 | 69 66 20 28 28 66 70 20 |(i) {...|if ((fp |
|00001ce0| 3d 20 66 6f 70 65 6e 28 | 4c 4f 43 4b 2c 20 22 77 |= fopen(|LOCK, "w|
|00001cf0| 22 29 29 20 3d 3d 20 4e | 55 4c 4c 29 20 7b 0a 09 |")) == N|ULL) {..|
|00001d00| 09 09 46 50 52 28 73 74 | 64 65 72 72 2c 20 22 70 |..FPR(st|derr, "p|
|00001d10| 73 2e 6d 6f 6e 69 74 6f | 72 3a 20 63 61 6e 27 74 |s.monito|r: can't|
|00001d20| 20 63 72 65 61 74 65 20 | 6c 6f 63 6b 20 25 73 5c | create |lock %s\|
|00001d30| 6e 22 2c 20 4c 4f 43 4b | 29 3b 0a 09 09 09 28 76 |n", LOCK|);....(v|
|00001d40| 6f 69 64 29 6b 69 6c 6c | 28 69 2c 20 53 49 47 4b |oid)kill|(i, SIGK|
|00001d50| 49 4c 4c 29 3b 0a 09 09 | 7d 0a 09 09 46 50 52 28 |ILL);...|}...FPR(|
|00001d60| 66 70 2c 20 22 25 64 5c | 6e 22 2c 20 69 29 3b 0a |fp, "%d\|n", i);.|
|00001d70| 09 09 28 76 6f 69 64 29 | 66 63 6c 6f 73 65 28 66 |..(void)|fclose(f|
|00001d80| 70 29 3b 0a 09 09 65 78 | 69 74 28 30 29 3b 0a 09 |p);...ex|it(0);..|
|00001d90| 7d 0a 7d 0a 0a 75 6e 6c | 6f 63 6b 28 29 0a 7b 0a |}.}..unl|ock().{.|
|00001da0| 09 28 76 6f 69 64 29 75 | 6e 6c 69 6e 6b 28 4c 4f |.(void)u|nlink(LO|
|00001db0| 43 4b 29 3b 0a 09 65 78 | 69 74 28 30 29 3b 0a 7d |CK);..ex|it(0);.}|
|00001dc0| 0a 53 48 41 52 5f 45 4f | 46 0a 63 68 6d 6f 64 20 |.SHAR_EO|F.chmod |
|00001dd0| 2b 78 20 27 70 73 2e 6d | 6f 6e 69 74 6f 72 2e 63 |+x 'ps.m|onitor.c|
|00001de0| 27 0a 66 69 20 23 20 65 | 6e 64 20 6f 66 20 6f 76 |'.fi # e|nd of ov|
|00001df0| 65 72 77 72 69 74 69 6e | 67 20 63 68 65 63 6b 0a |erwritin|g check.|
|00001e00| 23 09 45 6e 64 20 6f 66 | 20 73 68 65 6c 6c 20 61 |#.End of| shell a|
|00001e10| 72 63 68 69 76 65 0a 65 | 78 69 74 20 30 0a 0a 0a |rchive.e|xit 0...|
+--------+-------------------------+-------------------------+--------+--------+