ACTION SDtProcess
{
	LABEL		Process Manager
	ARG_COUNT	0
	ICON		SDtGears
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	sdtprocess
	DESCRIPTION	The Process Manager (SDtProcess) action run sdtprocess.
}

ACTION SDtProcess
{
	LABEL		Process Manager
        ARG_COUNT	1
        ARG_TYPE	HOST,WSMENU_This_Host
	ICON		SDtGears
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	ksh -c 'host="`cat \\"%Arg_1%\\"`"; \
			exec dtaction -execHost \${host#@} SDtProcess'
	DESCRIPTION	The Process Manager (SDtProcess) action run sdtprocess.
}

DATA_ATTRIBUTES PID
{
	ACTIONS		Open,LookUpOwner,Signal,Debug,Truss,TrussExecs,Pstack,Ptree,Kill
	ICON		SDtGears
	IS_TEXT		true
	MIME_TYPE	text/plain
	SUNV3_TYPE	text
	MEDIA		C_STRING
}

DATA_CRITERIA PID2
{
	DATA_ATTRIBUTES_NAME PID
	# 
	# Match "%5d " i.e. [0-9][0-9][0-9][0-9][0-9][ ][!/]
	CONTENT	0 string 0|0 string 1|0 string 2|0 string 3\
|0 string 4|0 string 5|0 string 6|0 string 7|0 string 8|0 string 9
	CONTENT	1 string 0|1 string 1|1 string 2|1 string 3\
|1 string 4|1 string 5|1 string 6|1 string 7|1 string 8|1 string 9
	CONTENT	2 string 0|2 string 1|2 string 2|2 string 3\
|2 string 4|2 string 5|2 string 6|2 string 7|2 string 8|2 string 9
	CONTENT	3 string 0|3 string 1|3 string 2|3 string 3\
|3 string 4|3 string 5|3 string 6|3 string 7|3 string 8|3 string 9
	CONTENT 4 string 0|4 string 1|4 string 2|4 string 3\
|4 string 4|4 string 5|4 string 6|4 string 7|4 string 8|4 string 9
	CONTENT		5 byte 040
	# Process basename cannot start with NUL / NL
	CONTENT		!6 byte 000&!6 string /&!6 byte 012&!6 byte 040
}

DATA_CRITERIA PID3
{
	DATA_ATTRIBUTES_NAME PID
	# 
	# Match " %4d " i.e. [ ][0-9][0-9][0-9][0-9][ ][!/]
	CONTENT	0 byte 040
	CONTENT	1 string 0|1 string 1|1 string 2|1 string 3\
|1 string 4|1 string 5|1 string 6|1 string 7|1 string 8|1 string 9
	CONTENT	2 string 0|2 string 1|2 string 2|2 string 3\
|2 string 4|2 string 5|2 string 6|2 string 7|2 string 8|2 string 9
	CONTENT	3 string 0|3 string 1|3 string 2|3 string 3\
|3 string 4|3 string 5|3 string 6|3 string 7|3 string 8|3 string 9
	CONTENT 4 string 0|4 string 1|4 string 2|4 string 3\
|4 string 4|4 string 5|4 string 6|4 string 7|4 string 8|4 string 9
	CONTENT		5 byte 040
	# Process basename cannot start with NUL / NL
	CONTENT		!6 byte 000&!6 string /&!6 byte 012&!6 byte 040
}

DATA_CRITERIA PID4
{
	DATA_ATTRIBUTES_NAME PID
	# 
	# Match "  %3d " i.e. [ ][ ][0-9][0-9][0-9][ ][!/]
	CONTENT	0 byte 040040
	CONTENT	2 string 0|2 string 1|2 string 2|2 string 3\
|2 string 4|2 string 5|2 string 6|2 string 7|2 string 8|2 string 9
	CONTENT	3 string 0|3 string 1|3 string 2|3 string 3\
|3 string 4|3 string 5|3 string 6|3 string 7|3 string 8|3 string 9
	CONTENT 4 string 0|4 string 1|4 string 2|4 string 3\
|4 string 4|4 string 5|4 string 6|4 string 7|4 string 8|4 string 9
	CONTENT		5 byte 040
	# Process basename cannot start with NUL / NL
	CONTENT		!6 byte 000&!6 string /&!6 byte 012&!6 byte 040
}

DATA_CRITERIA PID5
{
	DATA_ATTRIBUTES_NAME PID
	# 
	# Match "   %2d " i.e. [ ][ ][ ][0-9][0-9][ ][!/]
	CONTENT	0 byte 040040040
	CONTENT	3 string 0|3 string 1|3 string 2|3 string 3\
|3 string 4|3 string 5|3 string 6|3 string 7|3 string 8|3 string 9
	CONTENT 4 string 0|4 string 1|4 string 2|4 string 3\
|4 string 4|4 string 5|4 string 6|4 string 7|4 string 8|4 string 9
	CONTENT		5 byte 040
	# Process basename cannot start with NUL / NL
	CONTENT		!6 byte 000&!6 string /&!6 byte 012&!6 byte 040
}

DATA_CRITERIA PID6
{
	DATA_ATTRIBUTES_NAME PID
	# 
	# Match "    %1d " i.e. [ ][ ][ ][ ][0-9][ ][!/]
	CONTENT	0 byte 040040040040
	CONTENT 4 string 0|4 string 1|4 string 2|4 string 3\
|4 string 4|4 string 5|4 string 6|4 string 7|4 string 8|4 string 9
	CONTENT		5 byte 040
	# Process basename cannot start with NUL / NL
	CONTENT		!6 byte 000&!6 string /&!6 byte 012&!6 byte 040
}

ACTION Open
{
	LABEL		Open
	ARG_TYPE	PID
	TYPE		MAP
	MAP_ACTION	SDtProcess
}

ACTION Pstack
{
	LABEL		Show Stack...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
                exec /usr/proc/bin/pstack "\$pid"' ;
}

ACTION Ptree
{
	LABEL		Show Ancestry...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
		exec /usr/proc/bin/ptree "\$pid"' ;
}

ACTION Terminate
{
	LABEL		Terminate
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	sh -c 'pid="`cat \\"%Arg_1%\\"`"; \
			exec kill "\$pid"'
}

ACTION LookUpOwner
{
	LABEL		Look up Owner...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	ksh -c '\
                name="`awk \\"{print \\\\\$3}\\" \\"%Arg_1%\\"`" ;\
		exec sdtname -k "\$name"'
}

ACTION _Kill
{
	LABEL		Kill
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
		exec kill -KILL "\$pid"'
}

ACTION Suspend
{
	LABEL		Suspend
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	sh -c 'pid="`cat \\"%Arg_1%\\"`"; \
			exec kill -TSTP "\$pid"'
}

ACTION Resume
{
	LABEL		Resume
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	sh -c 'pid="`cat \\"%Arg_1%\\"`"; \
			exec kill -CONT "\$pid"'
}

ACTION Signal
{
	LABEL		Signal...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
		exec kill \
			-%"Signal (INT HUP ALRM ABRT TSTP CONT USR1...):"% \
			"\$pid"'
}

ACTION Debug
{
	LABEL		Debug
	TYPE		MAP
	MAP_ACTION	Workshop
}

ACTION Truss
{
	LABEL		Trace System Calls...
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	sh -c ' \
                        whence -p truss >/dev/null 2>&1; \
                        if [ $? -eq 0 ]; then \
                          TRUSS=`whence -p truss`; \
                        else \
                          TRUSS="/usr/bin/truss"; \
                        fi; \
			\${TRUSS} %"truss(1) Options ([-fa] [-[tv] [!]syscall...]):"% \
			"%(File)Arg_1"Command To Trace:"%" \
			%"Command Arguments:"% %(File)Args% \
			2>&1 | \${PAGER:-more}'
}

ACTION Truss
{
	LABEL		Trace System Calls...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
                if [ $? -eq 0 ]; then \
                  TRUSS=`whence -p truss`; \
                else \
                  TRUSS="/usr/bin/truss"; \
                fi; \
		\${TRUSS} %"truss(1) Options ([-fa] [-[tv] [!]syscall...]):"% \
			-p "\$pid" 2>&1 \
		| \${PAGER:-more}'
}

ACTION TrussExecs
{
	LABEL		Trace Children...
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
                if [ $? -eq 0 ]; then \
                  TRUSS=`whence -p truss`; \
                else \
                  TRUSS="/usr/bin/truss"; \
                fi; \
		\${TRUSS} -fa -texec,fork -s!CLD,ALRM \
			-p "\$pid" 2>&1 \
		| \${PAGER:-more}'
}

ACTION TrussRecursively
{
	LABEL		Truss Recursively
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	PERM_TERMINAL
	EXEC_STRING	sh -c 'pid="`cat \\"%Arg_1%\\"`"; \
                        if [ $? -eq 0 ]; then \
                          TRUSS=`whence -p truss`; \
                        else \
                          TRUSS="/usr/bin/truss"; \
                        fi; \
			\${TRUSS} -fa -p "\$pid" 2>&1 | \${PAGER:-more}'
}

ACTION Workshop
{
	LABEL		Workshop
	ARG_TYPE	CORE
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	sh -c ' \
				WHOSE=`whose "%(File)Arg_1%"`; \
				WHICH=`which \$WHOSE`; \
				exec workshop -D \$WHICH "%(File)Arg_1%"'
}

ACTION WorkshopProgram
{
	LABEL		Workshop Program...
	ARG_TYPE	CORE
	ARG_COUNT	2
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	workshop -D "%(File)Arg_2"Program:"%" "%(File)Arg_1%"
}

ACTION Workshop
{
	LABEL		Workshop
	ARG_TYPE	EXECUTABLE
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	EXEC_STRING	workshop -D "%(File)Arg_1%"
}

ACTION Workshop
{
	LABEL		Workshop
	ARG_TYPE	PID
	ARG_COUNT	1
	TYPE		COMMAND
	WINDOW_TYPE	NO_STDIO
	# cd up so workshop -D does not think %Arg_1% is a core file
	EXEC_STRING	ksh -c '\
		line="`head -1 \\"%Arg_1%\\"`"; \
		lineWithNoLeadingWhiteSpace=\${line##+( )}; \
		pid=\${lineWithNoLeadingWhiteSpace%% *}; \
		if [ -f "\$pid" ]; then cd ..; fi; \
		exec workshop -D - "\$pid"'
}
