wait for mount to complete before exiting

This commit is contained in:
rsc 2006-07-27 05:14:16 +00:00
parent 143cdf5758
commit a83ccf38d7
3 changed files with 12 additions and 2 deletions

View file

@ -37,6 +37,7 @@ extern char *fusemtpt;
void freefusemsg(FuseMsg *m); void freefusemsg(FuseMsg *m);
int fusefmt(Fmt*); int fusefmt(Fmt*);
void initfuse(char *mtpt); void initfuse(char *mtpt);
void waitfuse(void);
FuseMsg* readfusemsg(void); FuseMsg* readfusemsg(void);
void replyfuse(FuseMsg *m, void *arg, int narg); void replyfuse(FuseMsg *m, void *arg, int narg);
void replyfuseerrno(FuseMsg *m, int e); void replyfuseerrno(FuseMsg *m, int e);

View file

@ -763,7 +763,6 @@ mountfuse(char *mtpt)
close(p[0]); close(p[0]);
fd = recvfd(p[1]); fd = recvfd(p[1]);
close(p[1]); close(p[1]);
waitpid();
return fd; return fd;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
int pid, fd; int pid, fd;
@ -781,7 +780,6 @@ mountfuse(char *mtpt)
fprint(2, "exec mount_fusefs: %r\n"); fprint(2, "exec mount_fusefs: %r\n");
_exit(1); _exit(1);
} }
waitpid();
return fd; return fd;
#else #else
werrstr("cannot mount fuse on this system"); werrstr("cannot mount fuse on this system");
@ -789,6 +787,12 @@ mountfuse(char *mtpt)
#endif #endif
} }
void
waitfuse(void)
{
waitpid();
}
void void
unmountfuse(char *mtpt) unmountfuse(char *mtpt)
{ {

View file

@ -97,6 +97,11 @@ threadmain(int argc, char **argv)
sendp(fusechan, nil); /* sync */ sendp(fusechan, nil); /* sync */
proccreate(fusereader, nil, STACK); proccreate(fusereader, nil, STACK);
/*
* Now that we're serving FUSE, we can wait
* for the mount to finish and exit back to the user.
*/
waitfuse();
threadexits(0); threadexits(0);
} }