[Commit] nickle file.5c,1.1,1.2

Bart Massey commit at keithp.com
Mon Oct 13 00:15:26 PDT 2003


Committed by: bart

Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv2815

Modified Files:
	file.5c 
Log Message:
added mkchild()



Index: file.5c
===================================================================
RCS file: /local/src/CVS/nickle/file.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- file.5c	13 Oct 2003 05:48:57 -0000	1.1
+++ file.5c	13 Oct 2003 06:15:24 -0000	1.2
@@ -6,6 +6,27 @@
  */
 
 extend namespace File {
+    public stdnull = open("/dev/null", "r+");
+
+    public typedef union {
+	file input;
+	file output;
+	file error;
+    } childfd;
+
+    /* this is what happens when you fork() */
+    public int mkchild(string path, string[*] argv, childfd fds ...) {
+	file[3] filter_fds = { stdnull, ... };
+	for (int i = 0; i < dim(fds); i++) {
+	    union switch(fds[i]) {
+	    case input f: filter_fds[0] = f; break;
+	    case output f: filter_fds[1] = f; break;
+	    case error f: filter_fds[2] = f; break;
+	    }
+	}
+	return filter(path, argv, filter_fds);
+    }
+
     public namespace FileGlobals {
 
 	public int getchar ()




More information about the Commit mailing list