aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-08-11 16:44:43 +0000
committerrsc <devnull@localhost>2005-08-11 16:44:43 +0000
commitf7174317de5c84c22bdebbb97260c135fb215170 (patch)
treec3e6c8a35388c2bb72bb157f0ee2e53b223befc5 /src/cmd/rc
parent4ae2f414e20e32591f3b84c36fe721083fc0581e (diff)
downloadplan9port-f7174317de5c84c22bdebbb97260c135fb215170.tar.gz
plan9port-f7174317de5c84c22bdebbb97260c135fb215170.tar.bz2
plan9port-f7174317de5c84c22bdebbb97260c135fb215170.zip
Add rfork builtin.
Diffstat (limited to 'src/cmd/rc')
-rw-r--r--src/cmd/rc/plan9ish.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/cmd/rc/plan9ish.c b/src/cmd/rc/plan9ish.c
index 632e753f..efcbc99e 100644
--- a/src/cmd/rc/plan9ish.c
+++ b/src/cmd/rc/plan9ish.c
@@ -36,6 +36,7 @@ void execbind(void);
void execmount(void);
void execulimit(void);
void execumask(void);
+void execrfork(void);
builtin Builtin[]={
"cd", execcd,
"whatis", execwhatis,
@@ -49,8 +50,60 @@ builtin Builtin[]={
"flag", execflag,
"ulimit", execulimit,
"umask", execumask,
+ "rfork", execrfork,
0
};
+
+void
+execrfork(void)
+{
+ int arg;
+ char *s;
+
+ switch(count(runq->argv->words)){
+ case 1:
+ arg = RFENVG|RFNOTEG|RFNAMEG;
+ break;
+ case 2:
+ arg = 0;
+ for(s = runq->argv->words->next->word;*s;s++) switch(*s){
+ default:
+ goto Usage;
+ case 'n':
+ arg|=RFNAMEG; break;
+ case 'N':
+ arg|=RFCNAMEG;
+ break;
+ case 'e':
+ /* arg|=RFENVG; */ break;
+ case 'E':
+ arg|=RFCENVG; break;
+ case 's':
+ arg|=RFNOTEG; break;
+ case 'f':
+ arg|=RFFDG; break;
+ case 'F':
+ arg|=RFCFDG; break;
+ }
+ break;
+ default:
+ Usage:
+ pfmt(err, "Usage: %s [nNeEsfF]\n", runq->argv->words->word);
+ setstatus("rfork usage");
+ poplist();
+ return;
+ }
+ if(rfork(arg)==-1){
+ pfmt(err, "rc: %s failed\n", runq->argv->words->word);
+ setstatus("rfork failed");
+ }
+ else
+ setstatus("");
+ poplist();
+}
+
+
+
#define SEP '\1'
char **environp;
struct word *enval(s)