ref: 8c1d4604db54021b774b17eb7440685b4638163b
parent: 0be917ff4d11268824d58598f85348436010f2bd
author: cinap_lenrek <[email protected]>
date: Fri Oct 4 12:03:41 EDT 2013
page: close stdout, reopen stdout/stderr for external viewer and removed useless RFNAMEG flag we are not using stdout (fd=1) and it, so dup nullfd over it. this drops the old window reference when using with -w flag. the RFNAMEG flag isnt needed because we are calling newwindow() which forks the namespace for us. reopen stdin/stdout for the external viewer to the new window.
--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -1288,9 +1288,9 @@
fd = dup(fd, -1);
seek(fd, 0, 0);
}
- if(rfork(RFPROC|RFMEM|RFFDG|RFNOTEG|RFNAMEG|RFNOWAIT) == 0){
+ if(rfork(RFPROC|RFMEM|RFFDG|RFNOTEG|RFNOWAIT) == 0){
if(newwindow(nil) != -1){
- dupfds(fd, 1, 2, -1);
+ dupfds(fd, open("/dev/cons", OWRITE), open("/dev/cons", OWRITE), -1);
if((fd = open("/dev/label", OWRITE)) >= 0){
write(fd, label, strlen(label));
close(fd);
@@ -1520,6 +1520,7 @@
memset(&m, 0, sizeof(m));
if((nullfd = open("/dev/null", ORDWR)) < 0)
sysfatal("open: %r");
+ dup(nullfd, 1);
lru.lprev = &lru;
lru.lnext = &lru;
current = root = addpage(nil, "", nil, nil, -1);