OSProcess.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Jun 2015 06:22:00 +0100
branchjv
changeset 18487 8735bd9eee2f
parent 18011 deb0c3355881
child 19302 68355697fc84
permissions -rw-r--r--
Use inlined FNV1a hash for String ...and do not use __symbolHash(). Although currently the VM also uses FNV1a hash for Symbols, the __symbolHash() does not handle properly character with codepoint 0 (because '\0' is used as a string terminator). This causes problems with Unicode16/32Strigs whose version of FNV1a hash is using object size from header to determine string's end. Added Symbol>>hash that actually *uses* the __symbolHash() to make sure it's hash is the the same as used bu the VM. Symbols with zeroes are rare and there's no Unicode16/32Symbol. This commit fixes issue #65.

"{ Package: 'stx:libbasic' }"

Object subclass:#OSProcess
	instanceVariableNames:'pid parentPid commandLine'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Support'
!

!OSProcess class methodsFor:'documentation'!

documentation
"
    OSProcess is an abstract class. Instances represent operating system processes
    (as opposed to Smalltalk processes).

    [author:]
        Stefan Vogel (stefan@zwerg)

    [instance variables:]
        pid         SmallInteger    the process id
        parentPid   SmallInteger    the process id of the parent process
        commandLine String          the command line of the running command.

    [class variables:]

    [see also:]
        Process

"
! !

!OSProcess methodsFor:'accessing'!

commandLine
    ^ commandLine
!

commandLine:something
    commandLine := something.
!

parentPid
    ^ parentPid
!

parentPid:something
    parentPid := something.
!

pid
    ^ pid
!

pid:something
    pid := something.
! !

!OSProcess methodsFor:'printing'!

printOn:aStream
    aStream 
        nextPutAll:self className;
        nextPut:$(.
    pid printOn:aStream.
    aStream space.
    commandLine printOn:aStream.
    aStream nextPut:$)
! !

!OSProcess methodsFor:'queries'!

getProcessHandle
    "some OperatingSystems redefine this to resolve this to a processHandle
     (which must be explicitely freed later).
     Others simply return the pid here"

    ^ self subclassResponsibility
!

isAlive
    "answer true, if the process is still alive"

    ^ self subclassResponsibility
!

isDead
    "answer true, if the process is no longer alive"

    ^ self isAlive not
! !

!OSProcess methodsFor:'terminating'!

kill
    "kill the process - the process does not get the chance to clean up"
    
    ^ self subclassResponsibility.
!

killGroup
    "killl the processGroup - the processes does not get the chance to clean up"
    
    ^ self subclassResponsibility.
!

killWithAllChildren
    "terminate gracefully the process with all of its child processes"

    ^ self subclassResponsibility.
!

terminate
    "terminate the process gracefully"

    ^ self subclassResponsibility.
!

terminateGroup
    "terminate the process group.
     Under Windows, these is the same as terminateWithhAllChildren,
     under unix, this terminates a subset of all children"

   ^ self subclassResponsibility.
!

terminateWithAllChildren
    "terminate gracefully the process with all of its child processes"

    ^ self subclassResponsibility.
! !

!OSProcess class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libbasic/OSProcess.st,v 1.2 2011-03-08 17:01:30 stefan Exp $'
! !