sophuwu.site > manhttpd
MAN
sophuwu sophie@skisiel.com
Sun, 07 Jan 2024 05:52:11 +0100
commit

45dcc512bc79c214371bf87a27cf4efe4c849cd5

parent

145f20a71485aba34f5757a7172b76e919f861fd

1 files changed, 6 insertions(+), 5 deletions(-)

jump to
M main.gomain.go

@@ -7,6 +7,7 @@ "fmt"

"net/http" "os/exec" "strings" + "syscall" ) //go:embed font.css

@@ -73,16 +74,16 @@ cmd := exec.Command("/usr/lib/cgi-bin/man/"+exe, opt...)

var buff bytes.Buffer cmd.Stdout = &buff - - cmd.Env = append(cmd.Env, q, "REQUEST_METHOD="+r.Method, "SERVER_NAME=localhost:1234") + cmd.Env = append(cmd.Env, q) cmd.Env = append(cmd.Env, "MANPATH=/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man:/usr/X11R6/man:/opt/man:/snap/man") + var b bytes.Buffer + cmd.Stderr = &b err := cmd.Run() if err != nil { - fmt.Println(err) - http.Error(w, "Internal Server Error", 500) - return + syscall.Kill(cmd.Process.Pid, syscall.SIGKILL) } + fmt.Println(err) w.Header().Set("Content-Type", "text/html; charset=utf-8") w.WriteHeader(http.StatusOK)