Discussion:
[ast-developers] cd -@ hangs for FIFOs?
Lionel Cons
2013-09-17 18:24:16 UTC
Permalink
Can anyone else reproduce the problem that ksh from ast-ksh.20130913
can hang if I use cd -@ to add an attribute to a FIFO?

Lionel
Glenn Fowler
2013-09-17 18:51:15 UTC
Permalink
Post by Lionel Cons
Can anyone else reproduce the problem that ksh from ast-ksh.20130913
can you truss the shell and post the syscalls that deal with the fifo path?
maybe there should be an O_NONBLOCK in one of the opens?
Roland Mainz
2013-09-17 21:18:13 UTC
Permalink
Post by Lionel Cons
Can anyone else reproduce the problem that ksh from ast-ksh.20130913
Attached (as "astksh20130913_cd_xattr_fifo_nonblock001.diff.txt") is a
patch which fixes the problem by using |O_NONBLOCK| automagically if
we operate on /dev/file/xattr at ... ...

Glenn: Is the patch Ok for you ?

---

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u original/src/lib/libast/path/pathcanon.c build_xattr/src/lib/libast/path/pathcanon.c
--- src/lib/libast/path/pathcanon.c 2013-09-13 21:01:05.000000000 +0200
+++ src/lib/libast/path/pathcanon.c 2013-09-17 22:55:01.403278472 +0200
@@ -480,9 +480,9 @@
for (r = buf + (t - r); r > buf && *(r - 1) == '/'; r--);
*r = 0;
}
- if ((dev->fd = openat(dfd, buf, O_INTERCEPT|O_RDONLY|O_CLOEXEC|dev->oflags)) < 0)
+ if ((dev->fd = openat(dfd, buf, O_INTERCEPT|O_RDONLY|O_NONBLOCK|O_CLOEXEC|dev->oflags)) < 0)
r = 0;
- else if ((n = openat(dev->fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR)) < 0)
+ else if ((n = openat(dev->fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR|O_NONBLOCK)) < 0)
{
r = 0;
close(dev->fd);
@@ -717,11 +717,11 @@
if (r == canon)
r++;
*r = 0;
- dev->fd = openat(dfd, x, O_INTERCEPT|O_RDONLY|O_CLOEXEC|dev->oflags);
+ dev->fd = openat(dfd, x, O_INTERCEPT|O_RDONLY|O_NONBLOCK|O_CLOEXEC|dev->oflags);
*r = '/';
if (dev->fd < 0)
t = 0;
- else if ((n = openat(dev->fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR)) < 0)
+ else if ((n = openat(dev->fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR|O_NONBLOCK)) < 0)
{
close(dev->fd);
dev->fd = -1;
Glenn Fowler
2013-09-18 04:53:38 UTC
Permalink
this will be in the next alpha
--20cf3071cc96c4ea8d04e69adb76
Content-Type: text/plain; charset=ISO-8859-1
Post by Lionel Cons
Can anyone else reproduce the problem that ksh from ast-ksh.20130913
Attached (as "astksh20130913_cd_xattr_fifo_nonblock001.diff.txt") is a
patch which fixes the problem by using |O_NONBLOCK| automagically if
we operate on /dev/file/xattr at ... ...
Glenn: Is the patch Ok for you ?
---
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
--20cf3071cc96c4ea8d04e69adb76
Content-Type: text/plain; charset=US-ASCII;
name="astksh20130913_cd_xattr_fifo_nonblock001.diff.txt"
Content-Disposition: attachment;
filename="astksh20130913_cd_xattr_fifo_nonblock001.diff.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hlpmgxsk0
ZGlmZiAtciAtdSBvcmlnaW5hbC9zcmMvbGliL2xpYmFzdC9wYXRoL3BhdGhjYW5vbi5jIGJ1aWxk
X3hhdHRyL3NyYy9saWIvbGliYXN0L3BhdGgvcGF0aGNhbm9uLmMKLS0tIHNyYy9saWIvbGliYXN0
L3BhdGgvcGF0aGNhbm9uLmMJMjAxMy0wOS0xMyAyMTowMTowNS4wMDAwMDAwMDAgKzAyMDAKKysr
IHNyYy9saWIvb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