process

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 2 Imported by: 1

README

Process Examples

  • This package provides some easy-to-use functions to work with processes. Supported for Linux and Windows

List all processes

package main

import (
  "fmt"
  "log"

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

func main(){
  p, err := processes.GetProcesses() // func GetProcesses() ([]ps.Process, error)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(p)
}

Find name by pid

package main

import (
  "fmt"
  "log"

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

func main(){
  process_name, err := processes.FindNameByPid(1234) // func FindNameByPid(pid int) (string, error)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(process_name)
}

Find pid(s) by name

package main

import (
  "fmt"
  "log"

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

func main(){
  pids, err := process.FindPidByName("firefox") // func FindPidByName(name string) ([]int, error)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(pids)
}

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 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