From 620c9874c23fe5f22359335756d49101d8d1a8bb Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 4 Feb 2023 20:33:26 +0400 Subject: [PATCH] Added some more comments. --- configuration.go | 4 ++-- proc.go | 3 +++ processlist.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configuration.go b/configuration.go index 1af1763..b05a18a 100644 --- a/configuration.go +++ b/configuration.go @@ -8,7 +8,7 @@ import ( "strings" ) -// Configuration holds a list of process names to be tracked and a listen address. +// Configuration holds a configuration for the service. type Configuration struct { ListenAddress string IndentedOutput bool @@ -51,7 +51,7 @@ func LoadConfiguration(path string) (conf *Configuration, err error) { return conf, nil } -// StoreConfiguration writes Configuration into a file. +// StoreConfiguration writes configuration into a file. func (conf *Configuration) StoreConfiguration(path string) (err error) { var config strings.Builder diff --git a/proc.go b/proc.go index f1e8ca7..441cb0d 100644 --- a/proc.go +++ b/proc.go @@ -17,6 +17,9 @@ func GetProcessPIDs(name string) ([]int, error) { } for _, entry := range dir { + // This line demands a little clarification. Here we are making sure + // that the first character of a directory name is numeric. In ASCII + // all numerals are laying within 0x30-0x39 range. if entry.IsDir() && entry.Name()[0]>>0x4&0xf == 0x3 { cmdline, err := os.ReadFile("/proc/" + entry.Name() + "/cmdline") if err != nil { diff --git a/processlist.go b/processlist.go index fb12e1a..96152fe 100644 --- a/processlist.go +++ b/processlist.go @@ -4,10 +4,10 @@ import ( "encoding/xml" ) -// ProcessList is a map of processes' statuses. +// ProcessList is a map of processes' names and its statuses. type ProcessList map[string]bool -// MarshalXML implements Marshaler interface for a ProcessList. +// MarshalXML implements XML Marshaler interface for a ProcessList. func (l *ProcessList) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if len(*l) == 0 { return nil