Check if stdio pipes are nil for job containers/fix windows.Close usage#1115
Check if stdio pipes are nil for job containers/fix windows.Close usage#1115dcantah merged 1 commit intomicrosoft:masterfrom
Conversation
This change does two things: 1. Checks if the stdio pipes are nil before closing them via the CloseStdout, CloseStderr, CloseStdin methods. This just brings it inline with the other `cow.Process` implementations that check for nilness. 2. Fix an oversight where windows.Close was being used instead of windows.FreeLibrary after loading kernel32.dll Signed-off-by: Daniel Canter <dcanter@microsoft.com>
anmaxvl
left a comment
There was a problem hiding this comment.
LGTM. were we hitting nil deref somehow?
|
@anmaxvl Nope, but was scared of one happening somehow (and the other |
| return errors.Wrap(err, "failed to open process") | ||
| } | ||
| defer windows.Close(hProc) | ||
| defer func() { |
There was a problem hiding this comment.
These could just be left as the original defer windows.Close(hproc) with no functionality change.
There was a problem hiding this comment.
I think our linter was whining about it as we weren't handling the error, but begs the question of how it didn't whine the first time..
There was a problem hiding this comment.
Let me look what we can get away with
There was a problem hiding this comment.
internal\jobcontainers\process.go:252:27: Error return value of windows.FreeLibrary is not checked (errcheck)
defer windows.FreeLibrary(k32)
Seems to only care about the freelibrary for some odd reason
Related work items: microsoft#930, microsoft#962, microsoft#1004, microsoft#1008, microsoft#1039, microsoft#1045, microsoft#1046, microsoft#1047, microsoft#1052, microsoft#1053, microsoft#1054, microsoft#1057, microsoft#1058, microsoft#1060, microsoft#1061, microsoft#1063, microsoft#1064, microsoft#1068, microsoft#1069, microsoft#1070, microsoft#1071, microsoft#1074, microsoft#1078, microsoft#1079, microsoft#1081, microsoft#1082, microsoft#1083, microsoft#1084, microsoft#1088, microsoft#1090, microsoft#1091, microsoft#1093, microsoft#1094, microsoft#1096, microsoft#1098, microsoft#1099, microsoft#1102, microsoft#1103, microsoft#1105, microsoft#1106, microsoft#1108, microsoft#1109, microsoft#1115, microsoft#1116, microsoft#1122, microsoft#1123, microsoft#1126
Check if stdio pipes are nil for job containers/fix windows.Close usage
This change does two things:
CloseStderr, CloseStdin methods. This just brings it inline with the other
cow.Processimplementations that check for nilness.after loading kernel32.dll
Signed-off-by: Daniel Canter dcanter@microsoft.com