From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653755322198.tru64-unix-managers.marc@archive.invalid> From: redhatcat Date: Thu, 04 Apr 2002 04:34:03 +0000 To: tru64-unix-managers Subject: "C" program difference on V5.X vs V4.x X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653755322198 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------=_NextPart_000_00A3_01C1DB68.0A56B1A0" This is a multi-part message in MIME format. ------=_NextPart_000_00A3_01C1DB68.0A56B1A0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_00A4_01C1DB68.0A56B1A0" ------=_NextPart_001_00A4_01C1DB68.0A56B1A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ----- I am submitting this for someone who did not know about this = list (they are joining )---TIA---rhc Subject: C question The problem is this: within the Oracle space, on Tru64 we check for = processes using the ps command.=20 Sometimes, it misses processes, tells us they are not there when in fact = they are.=20 We have coded around this by trying it more than once with a delay if we = get a missing process. So we were looking for other ways to get process information, and we = wound up looking at the /proc filesystem. So I cobbled together a small program from pieces I found here and = there. It prints the pid, and two fields from the procfs.h prpsinfo = structure, pr_fname and pr_psargs. V4.x ---> This compiles and runs fine on a v4 machine. V5.x -->it compiles and runs on a v5 machine, but does not display all = the information expected in the psargs field IE on a v4 machine the output looks like: # ./getcmdline/getcmdline98 1 init /sbin/init -a 9 kloadsrv /sbin/kloadsrv 27 vold /sbin/vold 70 update /sbin/update 195 syslogd /usr/sbin/syslogd 199 binlogd /usr/sbin/binlogd 384 portmap /usr/sbin/portmap 389 mountd /usr/sbin/mountd -i 391 nfsd /usr/sbin/nfsd -t8 -u8 393 nfsiod /usr/sbin/nfsiod 7 396 rpc.statd /usr/sbin/rpc.statd 398 rpc.lockd /usr/sbin/rpc.lockd 480 xntpd /usr/sbin/xntpd -g -c /etc/ntp.conf 485 sendmail sendmail: accepting connections on 5309 emacs /freeware/bin/emacs -g 80x32 -fg gold -bg firebrick -cr = lightblue getcmdline.c 6160 ksh -ksh 6462 doit_on.exp expect -- bin/tnet decedidb_odr_dr 6558 telnetd telnetd 9470 more more /var/upgrade_guide.txt 13467 sh sh -c DB_RPT_HOME=3D/usr/users/db_rpts;export = DB_RPT_HOME;/usr/users/db_rpt/bin 13484 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on ne_o_prod = /usr/users/db_rpt/doitcmds 18276 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on _prod = /usr/users/db_rpt/doitcmd 22870 getcmdline98 /usr/users/tomas/getcmdline/getcmdline98 On a v5 machine the output looks like: xxddbs_expect_doit : ./getcmdline98 524288 kernel idle 524289 init /sbin/init 524290 kproc_creator_da 524291 icssvr_nomem_dae 524292 icssvr_throttle_ 524293 icssvr_daemon_fr 524294 icssvr_daemon_fr 524295 icssvr_nanny 524296 icscli_throttle_ 524297 icssvr_daemon_fr 524298 icssvr_daemon_fr 524299 icssvr_daemon_fr 524300 icssvr_daemon_fr 524301 icssvr_daemon_fr 524302 CFS daemon 524303 icssvr_daemon_pe 524304 icssvr_daemon_pe 524305 icssvr_daemon_pe 524307 kloadsrv /sbin/kloadsrv 524309 hotswapd /sbin/hotswapd 524387 esmd /usr/sbin/esmd 524398 update /sbin/update 524514 evmd /usr/sbin/evmd 524587 evmlogger /usr/sbin/evmlogger 524588 evmchmgr /usr/sbin/evmchmgr 524754 niffd /usr/sbin/niffd 524788 syslogd /usr/sbin/syslogd 524792 binlogd /usr/sbin/binlogd 529620 icssvr_daemon_pe 529621 icssvr_daemon_pe 529622 icssvr_daemon_pe 529623 icssvr_daemon_fr 529625 icssvr_daemon_pe 529627 icssvr_daemon_fr 529628 icssvr_daemon_fr 529629 icssvr_daemon_fr 529630 icssvr_daemon_fr 529643 icssvr_daemon_pe 620931 telnetd telnetd 620932 csh -csh 620952 csh -csh 621291 getcmdline98 ./getcmdline98 562469 saposcol /usr/sap/XXD/SYS/exe/run/saposcol 563789 icssvr_daemon_pe 563844 tnslsnr /oracle/XXD/817_64/bin/tnslsnr 563850 oracle ora_pmon_XXD 563852 oracle ora_dbw0_XXD 563854 oracle ora_lgwr_XXD 563856 oracle ora_ckpt_XXD 563858 oracle ora_smon_XXD 563860 oracle ora_reco_XXD 563862 oracle ora_arc0_XXD 563917 perl5.6.0 perl 563921 perl5.6.0 perl 563925 perl5.6.0 perl 564339 sapstart /usr/sap/XXD/SYS/exe/run/sapstart 564348 msg_server ms.sapXXD_DVEBMGS01 564349 disp+work dw.sapXXD_DVEBMGS01 564350 rslgcoll co.sapXXD_DVEBMGS01 564371 disp+work dw.sapXXD_DVEBMGS01 564372 disp+work dw.sapXXD_DVEBMGS01 564373 disp+work dw.sapXXD_DVEBMGS01 564382 oracle oracleXXD 564384 oracle oracleXXD 564386 oracle oracleXXD 564388 oracle oracleXXD C Code: sent as attachment =20 ------=_NextPart_001_00A4_01C1DB68.0A56B1A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

  ----- I am submitting this for someone who = did not=20 know about this list (they are joining )---TIA---rhc

 

Subject: C question

The problem is this: within the Oracle space, on Tru64 we check = for =20 processes using the ps command.

Sometimes, it misses processes, tells us they are not there when in = fact they=20 are.

We have coded around this by trying it more than once with a delay if = we get=20 a missing process.

So we were looking for other ways to get process information, and we = wound up=20 looking at the /proc filesystem.

So I cobbled together a small program from pieces I found here and = there. It=20 prints the pid, and two fields from the procfs.h prpsinfo structure, = pr_fname=20 and pr_psargs.

V4.x --->   This compiles and runs fine on a = v4=20 machine.

V5.x -->it compiles and runs on a v5 machine, but does not display = all the=20 information  expected  in the psargs field

 

 

IE on a v4 machine the output looks like:

 # ./getcmdline/getcmdline98

1 init /sbin/init -a

9 kloadsrv /sbin/kloadsrv

27 vold /sbin/vold

70 update /sbin/update

195 syslogd /usr/sbin/syslogd

199 binlogd /usr/sbin/binlogd

384 portmap /usr/sbin/portmap

389 mountd /usr/sbin/mountd -i

391 nfsd /usr/sbin/nfsd -t8 -u8

393 nfsiod /usr/sbin/nfsiod 7

396 rpc.statd /usr/sbin/rpc.statd

398 rpc.lockd /usr/sbin/rpc.lockd

480 xntpd /usr/sbin/xntpd -g -c /etc/ntp.conf

485 sendmail sendmail: accepting connections on

5309 emacs /freeware/bin/emacs -g 80x32 -fg gold -bg firebrick -cr = lightblue=20 getcmdline.c

6160 ksh -ksh

6462 doit_on.exp expect -- bin/tnet decedidb_odr_dr

6558 telnetd telnetd

9470 more more /var/upgrade_guide.txt

13467 sh sh -c DB_RPT_HOME=3D/usr/users/db_rpts;export=20 DB_RPT_HOME;/usr/users/db_rpt/bin

13484 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on ne_o_prod=20 /usr/users/db_rpt/doitcmds

18276 doit_on.exp expect -- /usr/users/db_rpt/bin/doit_on _prod=20 /usr/users/db_rpt/doitcmd

22870 getcmdline98 /usr/users/tomas/getcmdline/getcmdline98

 

 

 

On a v5 machine the output looks like:

xxddbs_expect_doit : ./getcmdline98

524288 kernel idle

524289 init /sbin/init

524290 kproc_creator_da

524291 icssvr_nomem_dae

524292 icssvr_throttle_

524293 icssvr_daemon_fr

524294 icssvr_daemon_fr

524295 icssvr_nanny

524296 icscli_throttle_

524297 icssvr_daemon_fr

524298 icssvr_daemon_fr

524299 icssvr_daemon_fr

524300 icssvr_daemon_fr

524301 icssvr_daemon_fr

524302 CFS daemon

524303 icssvr_daemon_pe

524304 icssvr_daemon_pe

524305 icssvr_daemon_pe

524307 kloadsrv /sbin/kloadsrv

524309 hotswapd /sbin/hotswapd

524387 esmd /usr/sbin/esmd

524398 update /sbin/update

524514 evmd /usr/sbin/evmd

524587 evmlogger /usr/sbin/evmlogger

524588 evmchmgr /usr/sbin/evmchmgr

524754 niffd /usr/sbin/niffd

524788 syslogd /usr/sbin/syslogd

524792 binlogd /usr/sbin/binlogd

529620 icssvr_daemon_pe

529621 icssvr_daemon_pe

529622 icssvr_daemon_pe

529623 icssvr_daemon_fr

529625 icssvr_daemon_pe

529627 icssvr_daemon_fr

529628 icssvr_daemon_fr

529629 icssvr_daemon_fr

529630 icssvr_daemon_fr

529643 icssvr_daemon_pe

620931 telnetd telnetd

620932 csh -csh

620952 csh -csh

621291 getcmdline98 ./getcmdline98

562469 saposcol /usr/sap/XXD/SYS/exe/run/saposcol

563789 icssvr_daemon_pe

563844 tnslsnr /oracle/XXD/817_64/bin/tnslsnr

563850 oracle ora_pmon_XXD

563852 oracle ora_dbw0_XXD

563854 oracle ora_lgwr_XXD

563856 oracle ora_ckpt_XXD

563858 oracle ora_smon_XXD

563860 oracle ora_reco_XXD

563862 oracle ora_arc0_XXD

563917 perl5.6.0 perl

563921 perl5.6.0 perl

563925 perl5.6.0 perl

564339 sapstart /usr/sap/XXD/SYS/exe/run/sapstart

564348 msg_server ms.sapXXD_DVEBMGS01

564349 disp+work dw.sapXXD_DVEBMGS01

564350 rslgcoll co.sapXXD_DVEBMGS01

564371 disp+work dw.sapXXD_DVEBMGS01

564372 disp+work dw.sapXXD_DVEBMGS01

564373 disp+work dw.sapXXD_DVEBMGS01

564382 oracle oracleXXD

564384 oracle oracleXXD

564386 oracle oracleXXD

564388 oracle oracleXXD

 

C     Code:   sent as attachment =  

 

 

------=_NextPart_001_00A4_01C1DB68.0A56B1A0-- ------=_NextPart_000_00A3_01C1DB68.0A56B1A0 Content-Type: text/plain; name="cprogram.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="cprogram.txt" #define PRG_MODULE "$Rcsfile$" #define PRG_VERSION " $Revision$ " /* ** Package : ** General Description ** ** ** Modification History ** ** Rev: Date Initials Reason ** ---- ---- -------- ------ **$Log$ ** ** ** Compile/Build Instructions ** ** ** */ /* ** PREPROCESSOR */ #include #include #include #include #include #include #include #include /* needed for process state constants */ #include = /* needed for process state constants */ #include = #include #include #include = #include #include #include = /* As of version 5.005_something it seems sv_undef has been supplanted = by PL_sv_undef. */ #ifdef sv_undef #define PL_sv_undef sv_undef #endif /* How many processes to get at once from table() */ #define PROCCNT 8 /* ** PROTOTYPES */ /* prototypes to make the compiler shut up */ /* ** EXTERNALS */ main (int argc, char *argv) { =20 /* ** FUNCTIONS */ /* ** ARRAYS */ char sFilename[16+1]; char pathbuf[MAXPATHLEN+1]; /* ** SCALARS */ int ifd =3D 0; int maxproc =3D 0; int procnum =3D 0; int procbase =3D 0; int psdata =3D 0; int nproc =3D 0; int idx1 =3D 0; int idx2 =3D 0; int ret =3D 0; /* ** POINTERS */ =20 /* ** STRUCTURES and UNIONS */ struct statvfs svfs; /* defined in */ struct tbl_procinfo pstbl[PROCCNT]; /* defined in */ struct prpsinfo psbuf; struct prcred pscredbuf; /* ** WINDOWS and FILES */ /* ** BEGIN MAIN PROCESSING */ if( statvfs("/proc", &svfs) =3D=3D -1 ) { (void) fprintf(stderr, "/proc unavailable...ABORTING\n"); exit(1); } /* Make sure /proc is mounted */ nproc =3D table(TBL_PROCINFO, 0, 0, MAXINT, 0); /* loop over all processes */ (void) fprintf(stderr, "PID\tfname\tpsargs\n"); (void) fprintf(stderr, = "------------------------------------------------\n"); for (idx1=3D0; idx1