ptools

This directory contains bash shell scripts in the file ptools.bash
that know how to locate PCSClite processes via the display
number, so that commands can be run on the pcscd process without
having to look up the PID.  This speeds things up and simplies
them went doing support work and investigations with PCSClite.

To use these scripts you can include them into your current
shell or just extend them into your login shell.

To include them you can do the following:

  . ptools.bash

The command line commands that will create are:

	p [<dpy#>] [<command>]
	plist <dpy#>
	stack <dpy#>

The following documents these commands and provides examples.

The p command:

     By default, the p command simply does a pstack of a pcscd
     instance.  With no arguments it will run pstack on the
     pcscd launcher.   

     If the <dpy#> is specified (integer display number from 
     $DISPLAY environment variable), it runs pstack on the 
     instance associated with that display.

     If the second argument is provided, that command will be
     run with the pid of the pscsd process indicated by <dpy>
     passed to it.  Example:

		$ p 3 pldd

		4722:   /usr/lib/smartcard/pcscd -I -x :3
		/usr/sfw/lib/libusb.so.1
		/lib/libdl.so.1
		/lib/libpthread.so.1
		/lib/libsocket.so.1
		/lib/libnsl.so.1
		/lib/libthread.so.1
		/lib/libc.so.1
		/platform/sun4u-us3/lib/libc_psr.so.1
		/usr/lib/smartcard/pcscdValidate-SunRay.so.1
		/opt/SUNWut/lib/libutsession.so.1
		/usr/openwin/lib/libX11.so.4
		/lib/libm.so.2
		/opt/SUNWut/lib/libutoscompat.so.1
		/opt/SUNWut/lib/libut.so.1
		/opt/SUNWut/lib/libutipv6.so.1
		/lib/libscf.so.1
		/lib/libdoor.so.1
		/lib/libuutil.so.1
		/lib/libgen.so.1
		/lib/libmd.so.1
		/platform/sun4u/lib/libmd_psr.so.1
		/lib/libmp.so.2
		/usr/lib/smartcard/pcscdValidate.so.1
		/opt/SUNWut/lib/ifdh_scbus.so.1
		/usr/openwin/lib/libXext.so.0
		/opt/SUNWut/lib/libusbut.so.1
		/opt/SUNWut/lib/libutdev.so.1


 
The plist command:

	plist <dpy#> 

	plist will list the pcscd processes related to 
	the display, including the launcher. example:

		$ plist 3

		908 /usr/lib/smartcard/pcscd -L    
		4722 /usr/lib/smartcard/pcscd -I -x :3
		4739 /opt/SUNWut/bin/utaction -x /usr/lib/smartcard/pcscd 
                     -k -x :3 -P 47222
The stack command:

	stack <dpy#>

	The stack command will run a *dynamically-refreshing*
	pstack command on the pcscd process associated with the specified
	display (<dpy#>) 

	It will clear the screen, run a pstack, clear to the 
	end of the screen from the last line of pstack output,
	home the cursor and go again.

	This will show pstacks changing rapidly when an active
	pcscd process is targeted and can be used to get an idea
	where pcscd is spending its time.  This can be helpful
	for identifying certain pathologies and diagnosing some
	bugs without always having to set up a more formal
	trace with a debugger, or dtruss, dtrace, apptrace or other tools.
