ref: 45c0c4128037a02b18d2b82ad35ae8784390a8ec
parent: 68537b7e9663c45f106b45d368dc0911a1dd87f3
author: cinap_lenrek <[email protected]>
date: Sat Oct 13 11:35:39 EDT 2012
urlencode: fix /fd/0 use
--- a/sys/src/cmd/urlencode.c
+++ b/sys/src/cmd/urlencode.c
@@ -44,9 +44,12 @@
} ARGEND;
if(argc == 1){
- close(0);
- if(open(*argv, OREAD) < 0)
+ int fd;
+
+ fd = open(*argv, OREAD);
+ if(fd < 0)
sysfatal("%r");
+ if(fd != 0) dup(fd, 0);
} else if(argc > 1)
usage();