Fixed -r, -R to named pipe "No such device or address" error

This commit is contained in:
Gerhard Rieger 2021-10-30 18:10:27 +02:00
parent 1a1cbb1598
commit 2fe44bbd78
2 changed files with 25 additions and 2 deletions

View file

@ -40,6 +40,11 @@ Corrections:
Test: SNIFF_RIGHT_TO_LEFT
Thanks to 1314 gsf for reporting this bug and sending a patch.
Options -r and -R, when opening a named pipe that has no actual reader,
failed with "No such device or address". To solve this problem, Socat
now opens the pipe in rw-Mode.
Thanks to Cody J.Soultz for sending a patch.
Testing:
Prevent the TIMESTAMP tests from sporadically failing due do seconds
overflow

22
socat.c
View file

@ -191,8 +191,17 @@ int main(int argc, const char *argv[]) {
#ifdef O_LARGEFILE
O_LARGEFILE|
#endif
O_NONBLOCK, 0664)) < 0)
O_NONBLOCK, 0664)) < 0) {
if (errno == ENXIO) {
if ((socat_opts.sniffleft = Open(a, O_CREAT|O_RDWR|O_APPEND|
#ifdef O_LARGEFILE
O_LARGEFILE|
#endif
O_NONBLOCK, 0664)) > 0)
break; /* try to open pipe rdwr */
}
Error2("option -r \"%s\": %s", a, strerror(errno));
}
break;
case 'R': if (arg1[0][2]) {
a = *arg1+2;
@ -207,8 +216,17 @@ int main(int argc, const char *argv[]) {
#ifdef O_LARGEFILE
O_LARGEFILE|
#endif
O_NONBLOCK, 0664)) < 0)
O_NONBLOCK, 0664)) < 0) {
if (errno == ENXIO) {
if ((socat_opts.sniffright = Open(a, O_CREAT|O_RDWR|O_APPEND|
#ifdef O_LARGEFILE
O_LARGEFILE|
#endif
O_NONBLOCK, 0664)) > 0)
break; /* try to open pipe rdwr */
}
Error2("option -R \"%s\": %s", a, strerror(errno));
}
break;
case 'b': if (arg1[0][2]) {
a = *arg1+2;