fixed a simple but critical bug in __MAKE_IMAP_NODE

This commit is contained in:
2019-08-26 10:29:26 +00:00
parent 4e6015ed36
commit d0d2a7af8c
4 changed files with 60 additions and 9 deletions

View File

@ -1491,6 +1491,55 @@ BEGIN {
}
~~~~~
~~~~~{.awk}
BEGIN {
if (sys::pipe(p0, p1, sys::O_NONBLOCK | sys::O_CLOEXEC) <= -1)
{
print "pipe error";
return -1;
}
a = sys::fork();
if (a <= -1)
{
print "fork error";
sys::close (p0);
sys::close (p1);
}
else if (a == 0)
{
## child
sys::close (p0);
stdout = sys::openfd(1);
sys::dup(p1, stdout);
print B"hello world";
print B"testing sys::dup()";
print B"writing to standard output..";
sys::close (p1);
sys::close (stdout);
}
else
{
sys::close (p1);
while (1)
{
n = sys::read(p0, k, 10);
if (n <= 0)
{
if (n == sys::RC_EAGAIN) continue; ## nonblock but data not available
if (n != 0) print "ERROR: " sys::errmsg();
break;
}
print "[" k "]";
}
sys::close (p0);
sys::wait(a);
}
}
~~~~~
~~~~~{.awk}
BEGIN {
d = sys::opendir("/etc", sys::DIR_SORT);