- func KillProcess(proc *os.Process) error
- type ExecResponse
- type RunParams
ErrCancelled is returned by WaitWithCancel in case it successfully manages to kill the running process.
func KillProcess ¶
KillProcess tries to kill the process being ran by RunParams We need this convoluted implementation because everything ran under the bash script is spawned as a different process and doesn't get killed by a regular process.Kill() For details see https://groups.google.com/forum/#!topic/golang-nuts/XoQ3RhFBJl8
type ExecResponse ¶
ExecResponse contains the return code and output generated by executing a command.
func RunCommands ¶
RunCommands executes the Commands specified in the RunParams using powershell on windows, and '/bin/bash -s' on everything else, passing the commands through as stdin, and collecting stdout and stderr. If a non-zero return code is returned, this is collected as the code for the response and this does not classify as an error.
Parameters for RunCommands. Commands contains one or more commands to be executed using bash or PowerShell. If WorkingDir is set, this is passed through. Similarly if the Environment is specified, this is used for executing the command. TODO: refactor this to use a config struct and a constructor. Remove todo and extra code from WaitWithCancel once this is done.
Process returns the *os.Process instance of the current running process This will allow us to kill the process if needed, or get more information on the process
Run sets up the command environment (environment variables, working dir) and starts the process. The commands are passed into bash on Linux machines and to powershell on Windows machines.
Wait blocks until the process exits, and returns an ExecResponse type containing stdout, stderr and the return code of the process. If a non-zero return code is returned, this is collected as the code for the response and this does not classify as an error.
func (*RunParams) WaitWithCancel ¶
WaitWithCancel waits until the process exits or until a signal is sent on the cancel channel. In case a signal is sent it first tries to kill the process and return ErrCancelled. If it fails at killing the process it will return anyway and report the problematic PID.