package tests
import (
)
const journalctlTimeout = time.Second
func ( int, string) (*fastjson.Object, error) {
, , := os.Pipe()
if != nil {
return nil,
}
defer func() { _ = .Close() }()
defer func() { _ = .Close() }()
:= time.Now().Add(journalctlTimeout)
if := .SetReadDeadline(); != nil {
return nil,
}
:= exec.Command("journalctl",
"-a", "-f",
"-o", "json",
"-n", "1",
"_PID="+strconv.Itoa(),
"MESSAGE="+,
)
.Stdout =
if := .Start(); != nil {
return nil,
}
defer func() {
_ = .Process.Kill()
_ = .Wait()
}()
var json.RawMessage
if := json.NewDecoder().Decode(&); != nil {
return nil,
}
, := fastjson.ParseBytes()
if != nil {
return nil,
}
return .Object()
}