我认为您的想法是正确的,似乎没有一种简洁的方法(在 TACL 中)来获取进程创建时间,因此您必须处理状态命令输出。这不会将变量作为 OUTV 参数,因此您可以使用文件并在其中进行一些处理,而不是在 TACL 中。
我将两个时间戳都转换为 #CONTIME 给出的空格分隔列表,然后将它们转换为 Julian 时间戳(见下文)。
这在(比如说)C 中可能更容易做到,您可以在其中调用 PROCESS_GETINFOLIST_ 直接获取创建时间戳。考虑到对时间戳的更好处理,在 OSS shell 中执行此操作甚至可能更容易。
?TACL ROUTINE
#FRAME
#PUSH tempfile
#SET tempfile XXTEMPXX
[#DEF MakeTimeList ROUTINE |BODY|
#FRAME
#PUSH month day year time hour min sec centi milli
SINK [#ARGUMENT/VALUE month/WORD]
SINK [#ARGUMENT/VALUE day/WORD]
SINK [#ARGUMENT COMMA]
SINK [#ARGUMENT/VALUE year/NUMBER]
SINK [#ARGUMENT/VALUE hour/NUMBER]
SINK [#ARGUMENT/VALUE min/NUMBER]
SINK [#ARGUMENT/VALUE sec/NUMBER]
SINK [#ARGUMENT/VALUE centi/NUMBER]
[#CASE [month]
|January| #SET month 1
|February| #SET month 2
|March| #SET month 3
|April| #SET month 4
|May| #SET month 5
|June| #SET month 6
|July| #SET month 7
|August| #SET month 8
|September| #SET month 9
|October| #SET month 10
|November| #SET month 11
|December| #SET month 12
]
#SET milli [#CHARGET centi 4 TO 6]
#SET centi [#CHARGET centi 1 TO 3]
#RESULT [year] [month] [day] [hour] [min] [sec] [centi] [milli]
#UNFRAME
]
#PUSH start now lines line pos process
SINK [#ARGUMENT/VALUE process/ PROCESSNAME]
[#IF NOT [#PROCESSEXISTS [process]] |THEN|
#OUTPUT [process] does not exist
]
status/out [tempfile]/[process],detail
edit [tempfile];cqab/:/ /a;cqab/./ /a;exit
filetovar [tempfile] lines
SINK [#PURGE [tempfile]]
#SET pos [#LINEFIND lines 1 Process Creation Time]
[#IF pos > 1 |THEN|
#SET line [#LINEGET lines [pos]]
#SET start [#CHARGET line 23 TO [#CHARCOUNT line]]
#SET start [MakeTimeList [start]]
#SETMANY start, [#COMPUTETIMESTAMP [start] ]
#SETMANY now, [#COMPUTETIMESTAMP [#CONTIME [#TIMESTAMP]] 0]
#OUTPUT [#COMPUTE ([now] - [start])/1000000] seconds have elapsed
]
#UNFRAME