1
0
Эх сурвалжийг харах

make popen cancellation-safe

close was the only cancellation point called from popen, but it left
popen with major resource leaks if any call to close got cancelled.
the easiest, cheapest fix is just to use a non-cancellable close
function.
Rich Felker 12 жил өмнө
parent
commit
9c21f4342c
1 өөрчлөгдсөн 7 нэмэгдсэн , 0 устгасан
  1. 7 0
      src/stdio/popen.c

+ 7 - 0
src/stdio/popen.c

@@ -1,4 +1,11 @@
 #include "stdio_impl.h"
+#include "syscall.h"
+
+static inline void nc_close(int fd)
+{
+	__syscall(SYS_close, fd);
+}
+#define close(x) nc_close(x)
 
 FILE *popen(const char *cmd, const char *mode)
 {