#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 17 Jul 2018 09:30:15 +0200
changeset 23213 bd67ea22139d
parent 23212 6d6e0212d313
child 23214 794c8f49ab79
#FEATURE by cg class: OSProcess class changed: #getTaskList unix support
OSProcess.st
--- a/OSProcess.st	Mon Jul 16 12:54:33 2018 +0200
+++ b/OSProcess.st	Tue Jul 17 09:30:15 2018 +0200
@@ -310,14 +310,36 @@
                             ProcessListEntry executableName:executableName processID:processID sessionName:userName
                         ]
                         as:OrderedCollection.
-        ^ entries
     ] ifFalse:[
-        ^ #()
+        lines := (PipeStream outputFromCommand:'ps') asStringCollection.
+        sepIdx := lines findFirst:[:line | line withoutSeparators first isDigit].
+        sepIdx == 0 ifTrue:[ ^ #() ].
+        entries := (lines from:(sepIdx + 1)) 
+                        collect:[:line |
+                            |s idx executableName processID tty time|
+
+                            s := line readStream.
+                            processID := Integer readFrom:s.
+                            s skipSeparators.
+                            tty := s upToSeparator.
+                            s skipSeparators.
+                            time := s upToSeparator.
+                            s skipSeparators.
+                            executableName := s upToEnd.
+                            (executableName startsWith:'-') ifTrue:[
+                                executableName := executableName copyFrom:2.
+                            ].    
+                            ProcessListEntry executableName:executableName processID:processID sessionName:nil
+                        ]
+                        as:OrderedCollection.
     ].
+    ^ entries
 
     "
      self getTaskList
     "
+
+    "Modified: / 16-07-2018 / 23:11:05 / Claus Gittinger"
 ! !
 
 !OSProcess methodsFor:'accessing'!