No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

process.go 823B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* File for Process-related structs and methods */
  2. package jsh
  3. import (
  4. "errors"
  5. )
  6. // Process is a struct for marshalling into JSON output for the ps utility.
  7. type Process struct {
  8. User string
  9. Pid string
  10. PercentCpu string
  11. PercentMem string
  12. Vsz string
  13. Rss string
  14. Tty string
  15. Stat string
  16. Start string
  17. Time string
  18. Command string
  19. }
  20. // NewProcess
  21. func NewProcess(args []string) (procPtr *Process, err error) {
  22. err = nil
  23. // 11 = number of fields in the Process struct
  24. if len(args) != 11 {
  25. procPtr = &Process{}
  26. err = errors.New("Unexpected number of columns")
  27. } else {
  28. // TODO: figure out nicer way to do this
  29. procPtr = &Process{
  30. args[0], args[1], args[2], args[3], args[4], args[5],
  31. args[6], args[7], args[8], args[9], args[10]}
  32. }
  33. return
  34. }