Benjamin Tyner
2019-Dec-06 01:46 UTC
[Rd] Error in close.connection(p) : ignoring SIGPIPE signal
Not sure if this is a bug, so posting here first. If I run: ?? cnt <- 0L ?? while (TRUE) { ? ? ?? cnt <- cnt + 1L ? ? ?? p <- pipe("echo /dev/stdin > /dev/null", open = "w") ? ? ?? writeLines("foobar", p) ? ? ?? tryCatch(close(p), error = function(e) { print(cnt); stop(e)}) ?? } then once cnt gets to around 650, it fails with: ?? [1] 654 ?? Error in close.connection(p) : ignoring SIGPIPE signal Should I not be using pipe() in this way? Here is my sessionInfo() ?? R version 3.6.0 (2019-04-26) ?? Platform: x86_64-pc-linux-gnu (64-bit) ?? Running under: Ubuntu 18.04.3 LTS ?? Matrix products: default ?? BLAS:?? /home/btyner/R360/lib64/R/lib/libRblas.so ?? LAPACK: /home/btyner/R360/lib64/R/lib/libRlapack.so ?? locale: ? ? [1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C ? ? [3] LC_TIME=en_US.UTF-8??????? LC_COLLATE=en_US.UTF-8 ? ? [5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8 ? ? [7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C ? ? [9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C ?? [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C ?? attached base packages: ?? [1] stats???? graphics? grDevices utils???? datasets? methods base ?? loaded via a namespace (and not attached): ?? [1] compiler_3.6.0 Regards, Ben
Andreas Kersting
2019-Dec-06 07:04 UTC
[Rd] Error in close.connection(p) : ignoring SIGPIPE signal
Hi Benjamin, you cannot pipe to echo, since it does not read from stdin. echo just echos is first arg, i.e. echo /dev/stdin > /dev/null will echo the string "/dev/stdin"to /dev/stdout, which is redirected to /dev/null. Try p <- pipe("cat > /dev/null", open = "w") instead. Regards, Andreas 2019-12-06 02:46 GMT+01:00 Benjamin Tyner<btyner at gmail.com>:> Not sure if this is a bug, so posting here first. If I run: > ?? cnt <- 0L > ?? while (TRUE) { > ? ? ?? cnt <- cnt + 1L > ? ? ?? p <- pipe("echo /dev/stdin > /dev/null", open = "w") > ? ? ?? writeLines("foobar", p) > ? ? ?? tryCatch(close(p), error = function(e) { print(cnt); stop(e)}) > ?? } > > then once cnt gets to around 650, it fails with: > > ?? [1] 654 > ?? Error in close.connection(p) : ignoring SIGPIPE signal > > Should I not be using pipe() in this way? Here is my sessionInfo() > > ?? R version 3.6.0 (2019-04-26) > ?? Platform: x86_64-pc-linux-gnu (64-bit) > ?? Running under: Ubuntu 18.04.3 LTS > > ?? Matrix products: default > ?? BLAS:?? /home/btyner/R360/lib64/R/lib/libRblas.so > ?? LAPACK: /home/btyner/R360/lib64/R/lib/libRlapack.so > > ?? locale: > ? ? [1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C > ? ? [3] LC_TIME=en_US.UTF-8??????? LC_COLLATE=en_US.UTF-8 > ? ? [5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8 > ? ? [7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C > ? ? [9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C > ?? [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > ?? attached base packages: > ?? [1] stats???? graphics? grDevices utils???? datasets? methods base > > ?? loaded via a namespace (and not attached): > ?? [1] compiler_3.6.0 > > Regards, > Ben > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
Benjamin Tyner
2019-Dec-06 12:29 UTC
[Rd] Error in close.connection(p) : ignoring SIGPIPE signal
Andreas, How right you are! Still, I find it curious that in the context of the while(TRUE) loop, I am allowed to do this 653 times, with failure on the 654th attempt. Perhaps there is something asynchronous going on? If I eliminate the looping, it does indeed fail (as expected) on the first attempt to close the pipe. Regards Ben On 12/6/19 2:04 AM, Andreas Kersting wrote:> Hi Benjamin, > > you cannot pipe to echo, since it does not read from stdin. > > echo just echos is first arg, i.e. echo /dev/stdin > /dev/null will echo the string "/dev/stdin"to /dev/stdout, which is redirected to /dev/null. > > Try > > p <- pipe("cat > /dev/null", open = "w") > > instead. > > Regards, > Andreas > > 2019-12-06 02:46 GMT+01:00 Benjamin Tyner<btyner at gmail.com>: >> Not sure if this is a bug, so posting here first. If I run: >> ?? cnt <- 0L >> ?? while (TRUE) { >> ? ? ?? cnt <- cnt + 1L >> ? ? ?? p <- pipe("echo /dev/stdin > /dev/null", open = "w") >> ? ? ?? writeLines("foobar", p) >> ? ? ?? tryCatch(close(p), error = function(e) { print(cnt); stop(e)}) >> ?? } >> >> then once cnt gets to around 650, it fails with: >> >> ?? [1] 654 >> ?? Error in close.connection(p) : ignoring SIGPIPE signal >> >> Should I not be using pipe() in this way? Here is my sessionInfo() >> >> ?? R version 3.6.0 (2019-04-26) >> ?? Platform: x86_64-pc-linux-gnu (64-bit) >> ?? Running under: Ubuntu 18.04.3 LTS >> >> ?? Matrix products: default >> ?? BLAS:?? /home/btyner/R360/lib64/R/lib/libRblas.so >> ?? LAPACK: /home/btyner/R360/lib64/R/lib/libRlapack.so >> >> ?? locale: >> ? ? [1] LC_CTYPE=en_US.UTF-8?????? LC_NUMERIC=C >> ? ? [3] LC_TIME=en_US.UTF-8??????? LC_COLLATE=en_US.UTF-8 >> ? ? [5] LC_MONETARY=en_US.UTF-8??? LC_MESSAGES=en_US.UTF-8 >> ? ? [7] LC_PAPER=en_US.UTF-8?????? LC_NAME=C >> ? ? [9] LC_ADDRESS=C?????????????? LC_TELEPHONE=C >> ?? [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C >> >> ?? attached base packages: >> ?? [1] stats???? graphics? grDevices utils???? datasets? methods base >> >> ?? loaded via a namespace (and not attached): >> ?? [1] compiler_3.6.0 >> >> Regards, >> Ben >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel
Seemingly Similar Threads
- Error in close.connection(p) : ignoring SIGPIPE signal
- Error in close.connection(p) : ignoring SIGPIPE signal
- installation: while running make, unable to run pdflatex on 'NEWS.tex'
- custom strip in lattice ignoring plotmath expressions for all but style = 1 (PR#8733)
- R-devel (rev 76409) fails 'make check': non-generic function 'isSymmetric' given to findMethods()