commit - 955a2ca78d7efc2787864e38a3d902df16fc2541
commit + 03417610742c4a67bb0345a8fa0fb4e13dee07f7
blob - d91d8906327c9c5165b63370b616ebe4d2b0258b
blob + ad5ecee08e39f72b7661a1b648faaaed6c8f775a
--- include/libc.h
+++ include/libc.h
/* extern int access(char*, int); */
extern long p9alarm(ulong);
extern int await(char*, int);
+extern int awaitfor(int, char*, int);
extern int awaitnohang(char*, int);
/* extern int bind(char*, char*, int); give up */
/* extern int brk(void*); <unistd.h> */
extern int p9sleep(long);
/* extern int stat(char*, uchar*, int); give up */
extern Waitmsg* p9wait(void);
+extern Waitmsg* p9waitfor(int);
extern Waitmsg* waitnohang(void);
extern int p9waitpid(void);
/* <unistd.h>
#undef open
#define open p9open
#define pipe p9pipe
+#define waitfor p9waitfor
#endif
extern Dir* dirstat(char*);
blob - b7d9265ab9a1b0f85660e746ef6c079287e10dbf
blob + afc5f9e344c3d82b68bce970bd1bf23c5a5e7258
--- src/lib9/await.c
+++ src/lib9/await.c
}
static int
-_await(char *str, int n, int opt)
+_await(int pid4, char *str, int n, int opt)
{
int pid, status, cd;
struct rusage ru;
ulong u, s;
for(;;){
- pid = wait3(&status, opt, &ru);
+ pid = wait4(pid4, &status, opt, &ru);
if(pid <= 0)
return -1;
u = ru.ru_utime.tv_sec*1000+((ru.ru_utime.tv_usec+500)/1000);
int
await(char *str, int n)
{
- return _await(str, n, 0);
+ return _await(-1, str, n, 0);
}
int
awaitnohang(char *str, int n)
{
- return _await(str, n, WNOHANG);
+ return _await(-1, str, n, WNOHANG);
}
+int
+awaitfor(int pid, char *str, int n)
+{
+ return _await(pid, str, n, 0);
+}
+
blob - 856f85c0f0d7f6f894ac444e3ef0f96e530dab99
blob + 31d8c02af7aba63d3944c8837a6c7a3cf5c1ae2e
--- src/lib9/wait.c
+++ src/lib9/wait.c
#include <libc.h>
static Waitmsg*
-_wait(int nohang)
+_wait(int n, char *buf)
{
- int n, l;
- char buf[512], *fld[5];
+ int l;
+ char *fld[5];
Waitmsg *w;
- n = (nohang ? awaitnohang : await)(buf, sizeof buf-1);
if(n <= 0)
return nil;
buf[n] = '\0';
Waitmsg*
wait(void)
{
- return _wait(0);
+ char buf[256];
+
+ return _wait(await(buf, sizeof buf-1), buf);
}
Waitmsg*
waitnohang(void)
{
- return _wait(1);
+ char buf[256];
+
+ return _wait(awaitnohang(buf, sizeof buf-1), buf);
}
+Waitmsg*
+waitfor(int pid)
+{
+ char buf[256];
+
+ return _wait(awaitfor(pid, buf, sizeof buf-1), buf);
+}
+