process

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 2 Imported by: 1

README

Process Examples

This directory 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/src/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/src/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/src/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

func FindNameByPid(pid int) (string, error)

func FindPidByName

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
JackTT - Gopher 🇻🇳