The code is like this:
cmd := exec.Command(os_.Args[0], os_.Args[1:]...)
cmd.SysProcAttr = &builtin_syscall.SysProcAttr{
Credential: &builtin_syscall.Credential{
Uid: uint32(runUid),
Gid: uint32(runGids[0]),
Groups: gidsUint,
},
Setsid: true,
}
f,err :=os_.Open("/var/logs/std_0.log")
if err != nil{
fmt.Printf("failed to open file: %s\n",err.Error())
cmd.Stdout = f
cmd.Stderr = f
} else {
cmd.Stdout = os_.Stdout
cmd.Stderr = os_.Stderr
}
The /proc/${pid}/fd files list:
lr-x------ 1 steve coder 64 9月 26 15:29 0 -> /dev/null
lrwx------ 1 steve coder 64 9月 26 15:29 1 -> /var/logs/std_0.log
lrwx------ 1 steve coder 64 9月 26 15:29 10 -> socket:[1137628899]
lrwx------ 1 steve coder 64 9月 26 15:29 11 -> socket:[1137631303]
lrwx------ 1 steve coder 64 9月 26 15:29 12 -> socket:[1137630589]
However the log is still redirected to systemd's journal log instead of the dedicated file. Can somebody explain it?