Little fixes.
This commit is contained in:
parent
be36ff6885
commit
b1455f33a8
10 changed files with 68 additions and 15 deletions
|
|
@ -121,18 +121,24 @@ threadmain(int argc, char **argv)
|
||||||
case 'd':
|
case 'd':
|
||||||
debug = 1;
|
debug = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
name = EARGF(usage());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
prog = argv;
|
prog = argv;
|
||||||
|
|
||||||
if(argc > 0){
|
if(name == nil){
|
||||||
|
if(argc > 0)
|
||||||
name = argv[0];
|
name = argv[0];
|
||||||
argc--;
|
else{
|
||||||
argv++;
|
name = sysname();
|
||||||
}else
|
if(name == nil)
|
||||||
name = "gnot";
|
name = "gnot";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
threadnotify(nopipes, 1);
|
threadnotify(nopipes, 1);
|
||||||
if((fs = nsmount("acme", "")) == 0)
|
if((fs = nsmount("acme", "")) == 0)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ main(int argc, char **argv)
|
||||||
case 'c':
|
case 'c':
|
||||||
stdout++;
|
stdout++;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
/* force */
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
/*
|
/*
|
||||||
* gnu tar expects bzip2 -d to decompress
|
* gnu tar expects bzip2 -d to decompress
|
||||||
|
|
|
||||||
|
|
@ -1934,9 +1934,9 @@ void doevent(void)
|
||||||
if (mobile) {
|
if (mobile) {
|
||||||
mvtime = ev.mouse.msec + Mv_delay;
|
mvtime = ev.mouse.msec + Mv_delay;
|
||||||
prepare_mv(cur_sel.fp);
|
prepare_mv(cur_sel.fp);
|
||||||
}
|
if (!lift_button(1, &ev.mouse, mvtime))
|
||||||
if (!lift_button(1, &ev.mouse, mvtime) && mobile)
|
|
||||||
save_mv(do_move(1, &ev.mouse));
|
save_mv(do_move(1, &ev.mouse));
|
||||||
|
}
|
||||||
} else if (ev.mouse.buttons & But2)
|
} else if (ev.mouse.buttons & But2)
|
||||||
do_emenu(2, &ev.mouse);
|
do_emenu(2, &ev.mouse);
|
||||||
else if (ev.mouse.buttons & But3)
|
else if (ev.mouse.buttons & But3)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,9 @@ main(int argc, char *argv[])
|
||||||
exec("gunzip", oargv);
|
exec("gunzip", oargv);
|
||||||
sysfatal("exec gunzip failed");
|
sysfatal("exec gunzip failed");
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
/* force */
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ struct thread{
|
||||||
int iflag; /* interactive? */
|
int iflag; /* interactive? */
|
||||||
int lineno; /* linenumber */
|
int lineno; /* linenumber */
|
||||||
int pid; /* process for Xpipewait to wait for */
|
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 */
|
char status[NSTATUS]; /* status for Xpipewait */
|
||||||
tree *treenodes; /* tree nodes created by this process */
|
tree *treenodes; /* tree nodes created by this process */
|
||||||
thread *ret; /* who continues when this finishes */
|
thread *ret; /* who continues when this finishes */
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,17 @@ _p9uproc(int inhandler)
|
||||||
h = 0;
|
h = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inhandler)
|
if(inhandler){
|
||||||
sysfatal("did not find uproc in signal handler");
|
fprint(2, "%s: did not find uproc for pid %d in signal handler\n", argv0, pid);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
/* need to allocate */
|
/* need to allocate */
|
||||||
while((up = mallocz(sizeof(Uproc), 1)) == nil)
|
while((up = mallocz(sizeof(Uproc), 1)) == nil)
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
|
|
||||||
up = mallocz(sizeof(Uproc), 1);
|
fprint(2, "alloc uproc for pid %d\n", pid);
|
||||||
|
up->pid = pid;
|
||||||
lock(&uproclock);
|
lock(&uproclock);
|
||||||
h = pid%PIDHASH;
|
h = pid%PIDHASH;
|
||||||
for(i=0; i<PIDHASH; i++){
|
for(i=0; i<PIDHASH; i++){
|
||||||
|
|
@ -79,6 +82,7 @@ _p9uprocdie(void)
|
||||||
int pid, i, h;
|
int pid, i, h;
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
fprint(2, "reap uproc for pid %d\n", pid);
|
||||||
h = pid%PIDHASH;
|
h = pid%PIDHASH;
|
||||||
for(i=0; i<PIDHASH; i++){
|
for(i=0; i<PIDHASH; i++){
|
||||||
up = alluproc[h];
|
up = alluproc[h];
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,19 @@ extern int __isthreaded;
|
||||||
int
|
int
|
||||||
ffork(int flags, void(*fn)(void*), void *arg)
|
ffork(int flags, void(*fn)(void*), void *arg)
|
||||||
{
|
{
|
||||||
|
int pid;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
|
_p9uproc(0);
|
||||||
__isthreaded = 1;
|
__isthreaded = 1;
|
||||||
p = malloc(16384);
|
p = malloc(16384);
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
return -1;
|
return -1;
|
||||||
memset(p, 0xFE, 16384);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,41 @@
|
||||||
|
#include <u.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <lib9.h>
|
#include <libc.h>
|
||||||
|
#include "9proc.h"
|
||||||
|
|
||||||
int fforkstacksize = 16384;
|
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
|
int
|
||||||
ffork(int flags, void (*fn)(void*), void *arg)
|
ffork(int flags, void (*fn)(void*), void *arg)
|
||||||
{
|
{
|
||||||
|
void **v;
|
||||||
char *p;
|
char *p;
|
||||||
int cloneflag, pid;
|
int cloneflag, pid;
|
||||||
|
|
||||||
|
_p9uproc(0);
|
||||||
p = malloc(fforkstacksize);
|
p = malloc(fforkstacksize);
|
||||||
if(p == nil)
|
v = malloc(sizeof(void*)*2);
|
||||||
|
if(p==nil || v==nil){
|
||||||
|
free(p);
|
||||||
|
free(v);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
cloneflag = 0;
|
cloneflag = 0;
|
||||||
flags &= ~RFPROC;
|
flags &= ~RFPROC;
|
||||||
if(flags&RFMEM){
|
if(flags&RFMEM){
|
||||||
|
|
@ -29,9 +52,13 @@ ffork(int flags, void (*fn)(void*), void *arg)
|
||||||
flags &= ~RFNOWAIT;
|
flags &= ~RFNOWAIT;
|
||||||
if(flags){
|
if(flags){
|
||||||
fprint(2, "unknown rfork flags %x\n", flags);
|
fprint(2, "unknown rfork flags %x\n", flags);
|
||||||
|
free(p);
|
||||||
|
free(v);
|
||||||
return -1;
|
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)
|
if(pid < 0)
|
||||||
free(p);
|
free(p);
|
||||||
return pid;
|
return pid;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,11 @@ ffork(int flags, void(*fn)(void*), void *arg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_p9uproc(0);
|
||||||
if(pthread_create(&tid, NULL, (void*(*)(void*))fn, arg) < 0)
|
if(pthread_create(&tid, NULL, (void*(*)(void*))fn, arg) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if((int)tid == 0)
|
||||||
|
_p9uproc(0);
|
||||||
return (int)tid;
|
return (int)tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ extern void p9main(int, char**);
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
_p9uproc(0);
|
||||||
p9main(argc, argv);
|
p9main(argc, argv);
|
||||||
exits("main");
|
exits("main");
|
||||||
return 99;
|
return 99;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue