process

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 2 Imported by: 0

README

Process Examples

  • Every function is different for Linux or Windows

List all processes

package main

import (
  "fmt"
  "log"

  "github.com/D3Ext/maldev/process"
)

func main(){
  // Linux
  p, err := processes.GetLinuxProcesses()
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(p)

  // Windows
  p2, err := process.GetWinProcesses()
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(p2)
}

Find name by pid

package main

import (
  "fmt"
  "log"

  "github.com/D3Ext/maldev/process"
)

func main(){
  // Linux
  process_name, err := processes.GetNameByPidLin(1234)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(process_name)

  // Windows
  process_name2, err := process.GetNameByPidWin(1234)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(process_name2)
}

Find pid(s) by name

package main

import (
  "fmt"
  "log"

  "github.com/D3Ext/maldev/process"
)

func main(){
  // Linux
  pids, err := process.GetPidByNameLin("firefox")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(pids)

  // Windows
  pids2, err := process.GetPidByNameWin("firefox.exe")
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(pids2)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindNameByPid added in v0.1.2

func FindNameByPid(pid int) (string, error)

func FindPidByName added in v0.1.2

func FindPidByName(name string) ([]int, error)

func GetLinuxProcesses added in v0.1.1

func GetLinuxProcesses() ([]ps.Process, error)

func GetNameByPidLin added in v0.1.1

func GetNameByPidLin(pid int) (string, error)

func GetPidByNameLin added in v0.1.1

func GetPidByNameLin(name string) ([]int, error)

func GetProcesses

func GetProcesses() ([]ps.Process, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL