diff options
-rw-r--r-- | src/cmd/9term/win.c | 18 | ||||
-rw-r--r-- | src/cmd/bzip2/bzip2.c | 3 | ||||
-rw-r--r-- | src/cmd/draw/gview.c | 4 | ||||
-rw-r--r-- | src/cmd/gzip/gzip.c | 3 | ||||
-rw-r--r-- | src/cmd/rc/exec.h | 1 | ||||
-rw-r--r-- | src/lib9/_p9proc.c | 10 | ||||
-rw-r--r-- | src/lib9/ffork-FreeBSD.c | 7 | ||||
-rw-r--r-- | src/lib9/ffork-Linux.c | 33 | ||||
-rw-r--r-- | src/lib9/ffork-pthread.c | 3 | ||||
-rw-r--r-- | src/lib9/main.c | 1 |
10 files changed, 68 insertions, 15 deletions
diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c index f341c102..a92c1656 100644 --- a/src/cmd/9term/win.c +++ b/src/cmd/9term/win.c @@ -121,18 +121,24 @@ threadmain(int argc, char **argv) case 'd': debug = 1; break; + case 'n': + name = EARGF(usage()); + break; default: usage(); }ARGEND prog = argv; - if(argc > 0){ - name = argv[0]; - argc--; - argv++; - }else - name = "gnot"; + if(name == nil){ + if(argc > 0) + name = argv[0]; + else{ + name = sysname(); + if(name == nil) + name = "gnot"; + } + } threadnotify(nopipes, 1); if((fs = nsmount("acme", "")) == 0) diff --git a/src/cmd/bzip2/bzip2.c b/src/cmd/bzip2/bzip2.c index e7ac9953..cc21a57c 100644 --- a/src/cmd/bzip2/bzip2.c +++ b/src/cmd/bzip2/bzip2.c @@ -38,6 +38,9 @@ main(int argc, char **argv) case 'c': stdout++; break; + case 'f': + /* force */ + break; case 'd': /* * gnu tar expects bzip2 -d to decompress diff --git a/src/cmd/draw/gview.c b/src/cmd/draw/gview.c index 5e80ee2a..0508d2dc 100644 --- a/src/cmd/draw/gview.c +++ b/src/cmd/draw/gview.c @@ -1934,9 +1934,9 @@ void doevent(void) if (mobile) { mvtime = ev.mouse.msec + Mv_delay; prepare_mv(cur_sel.fp); + if (!lift_button(1, &ev.mouse, mvtime)) + save_mv(do_move(1, &ev.mouse)); } - if (!lift_button(1, &ev.mouse, mvtime) && mobile) - save_mv(do_move(1, &ev.mouse)); } else if (ev.mouse.buttons & But2) do_emenu(2, &ev.mouse); else if (ev.mouse.buttons & But3) diff --git a/src/cmd/gzip/gzip.c b/src/cmd/gzip/gzip.c index f37405b9..f4038b88 100644 --- a/src/cmd/gzip/gzip.c +++ b/src/cmd/gzip/gzip.c @@ -52,6 +52,9 @@ main(int argc, char *argv[]) exec("gunzip", oargv); sysfatal("exec gunzip failed"); break; + case 'f': + /* force */ + break; case 'v': verbose++; break; diff --git a/src/cmd/rc/exec.h b/src/cmd/rc/exec.h index fbfe2dbb..1704b6f3 100644 --- a/src/cmd/rc/exec.h +++ b/src/cmd/rc/exec.h @@ -51,6 +51,7 @@ struct thread{ int iflag; /* interactive? */ int lineno; /* linenumber */ int pid; /* process for Xpipewait to wait for */ + int done; /* have we seen a wait message for this process? */ char status[NSTATUS]; /* status for Xpipewait */ tree *treenodes; /* tree nodes created by this process */ thread *ret; /* who continues when this finishes */ diff --git a/src/lib9/_p9proc.c b/src/lib9/_p9proc.c index 9454d079..813c3d9b 100644 --- a/src/lib9/_p9proc.c +++ b/src/lib9/_p9proc.c @@ -45,14 +45,17 @@ _p9uproc(int inhandler) h = 0; } - if(inhandler) - sysfatal("did not find uproc in signal handler"); + if(inhandler){ + fprint(2, "%s: did not find uproc for pid %d in signal handler\n", argv0, pid); + abort(); + } /* need to allocate */ while((up = mallocz(sizeof(Uproc), 1)) == nil) sleep(1000); - up = mallocz(sizeof(Uproc), 1); +fprint(2, "alloc uproc for pid %d\n", pid); + up->pid = pid; lock(&uproclock); h = pid%PIDHASH; for(i=0; i<PIDHASH; i++){ @@ -79,6 +82,7 @@ _p9uprocdie(void) int pid, i, h; pid = getpid(); +fprint(2, "reap uproc for pid %d\n", pid); h = pid%PIDHASH; for(i=0; i<PIDHASH; i++){ up = alluproc[h]; diff --git a/src/lib9/ffork-FreeBSD.c b/src/lib9/ffork-FreeBSD.c index 3829bb2d..71945edc 100644 --- a/src/lib9/ffork-FreeBSD.c +++ b/src/lib9/ffork-FreeBSD.c @@ -4,14 +4,19 @@ extern int __isthreaded; int ffork(int flags, void(*fn)(void*), void *arg) { + int pid; void *p; + _p9uproc(0); __isthreaded = 1; p = malloc(16384); if(p == nil) return -1; memset(p, 0xFE, 16384); - return rfork_thread(RFPROC|flags, (char*)p+16000, (int(*)(void*))fn, arg); + pid = rfork_thread(RFPROC|flags, (char*)p+16000, (int(*)(void*))fn, arg); + if(pid == 0) + _p9uproc(0); + return pid; } /* diff --git a/src/lib9/ffork-Linux.c b/src/lib9/ffork-Linux.c index 3b5c8ee0..8ec5ec3e 100644 --- a/src/lib9/ffork-Linux.c +++ b/src/lib9/ffork-Linux.c @@ -1,18 +1,41 @@ +#include <u.h> #include <sched.h> #include <signal.h> -#include <lib9.h> +#include <libc.h> +#include "9proc.h" int fforkstacksize = 16384; +static int +tramp(void *v) +{ + void (*fn)(void*), *arg; + void **v2; + + _p9uproc(0); + v2 = v; + fn = v2[0]; + arg = v2[1]; + free(v2); + fn(arg); + return 0; +} + int ffork(int flags, void (*fn)(void*), void *arg) { + void **v; char *p; int cloneflag, pid; + _p9uproc(0); p = malloc(fforkstacksize); - if(p == nil) + v = malloc(sizeof(void*)*2); + if(p==nil || v==nil){ + free(p); + free(v); return -1; + } cloneflag = 0; flags &= ~RFPROC; if(flags&RFMEM){ @@ -29,9 +52,13 @@ ffork(int flags, void (*fn)(void*), void *arg) flags &= ~RFNOWAIT; if(flags){ fprint(2, "unknown rfork flags %x\n", flags); + free(p); + free(v); return -1; } - pid = clone((int(*)(void*))fn, p+fforkstacksize-16, cloneflag, arg); + v[0] = fn; + v[1] = arg; + pid = clone(tramp, p+fforkstacksize-16, cloneflag, v); if(pid < 0) free(p); return pid; diff --git a/src/lib9/ffork-pthread.c b/src/lib9/ffork-pthread.c index ff61ed10..24b987b3 100644 --- a/src/lib9/ffork-pthread.c +++ b/src/lib9/ffork-pthread.c @@ -14,8 +14,11 @@ ffork(int flags, void(*fn)(void*), void *arg) return -1; } + _p9uproc(0); if(pthread_create(&tid, NULL, (void*(*)(void*))fn, arg) < 0) return -1; + if((int)tid == 0) + _p9uproc(0); return (int)tid; } diff --git a/src/lib9/main.c b/src/lib9/main.c index 4a429054..3ff63fd6 100644 --- a/src/lib9/main.c +++ b/src/lib9/main.c @@ -7,6 +7,7 @@ extern void p9main(int, char**); int main(int argc, char **argv) { + _p9uproc(0); p9main(argc, argv); exits("main"); return 99; |