[Rd] config.site settings for M3 Mac typo in manual?

2024-05-20 Thread Duncan Murdoch
I've just upgraded to an M3 Mac laptop, and I'm working through getting 
the right configure settings to build R.


The Installation and Administration manual says to have this in config.site:

FFLAGS="-g -O2 -mmacos-version-min=11.0"
FCFLAGS="-g -O2 -mmacos-version-min=11.0"

but those give an error on my system, with it suggesting the FFLAGS and 
FCFLAGS version option should be -mmacosx-version-min=11.0.  I don't 
know if that's a typo or a change.


Besides

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Output pipes to TTY hang

2024-05-20 Thread Tomas Kalibera



On 5/20/24 07:36, Zafer Barutcuoglu wrote:

Hi,

I am seeing this on Linux as well as MacOS: Opening any output pipe from R 4.4.0 to TTY programs 
like "less"/"more" hangs, SIGINT-proof:

$ R/4.4.0/bin/Rscript -e 'pipe("less", "w")'
$ R/4.4.0/bin/Rscript -e 'cat("test", file="|less")
$ R/4.4.0/bin/Rscript -e 'cat("test", file="|more")

R 4.3.3 and earlier have been working fine:

$ R/4.3.3/bin/Rscript -e 'pipe("less", "w")'
$ R/4.3.3/bin/Rscript -e 'cat("test", file="|less")
$ R/4.3.3/bin/Rscript -e 'cat("test", file="|more")


I've tried the first example and it doesn't work for me even in R 4.3.3 
on Linux, so I can't easily test what changed the behavior for you, but 
it was very likely a bugfix for PR#17764. Now the pipe() uses a special 
process group to protect the processes (assumed to be background) from 
the terminal.


If you are interested in the details behind this, see the bug report 
discussion or the blog post (below), and the source code.


A perhaps slightly over-simplified description is that tasks executed 
via pipe() and (file="|") and system(wait="FALSE") are background tasks, 
which should not be interruptible e.g. by Ctrl+C. This was fixed in R 
4.4, which required significant changes of the underlying implementation.


To support the very rare case when a task executed via 
system(wait="FALSE") should receive signals from a console, because it 
is to logically implement an interactive task using background tasks, 
there is now an argument "receive.console.signals", which can be used to 
override this. This is used by the R's parallel package to implement 
interactive computation on a cluster.


Your use case seems to be running an interactive task using pipe(). 
Currently, there is no argument of pipe() to allow this as we didn't 
anticipate anyone would actually be doing this - and, on my system, it 
doesn't work even in R 4.3.3.


I assume the examples above are narrowed down cases to reproduce the 
change in behavior. If there was a plausible, realistic example that 
would indicate the need to add such argument to pipe(), it could be 
considered, but perhaps it would be more natural to use 
system(wait=FALSE,receive.console.signals=TRUE), anyway?


Best
Tomas

https://blog.r-project.org/2023/05/23/not-interrupting-background-tasks-with-ctrl-c/index.html
https://bugs.r-project.org/show_bug.cgi?id=17764



R 4.4.0 also works fine with non-TTY output pipes:

$ R/4.4.0/bin/Rscript -e 'pipe("cat", "w")'
$ R/4.4.0/bin/Rscript -e 'cat("test", file="|cat")
$ R/4.4.0/bin/Rscript -e 'cat("Hi!\n", file="|tr i o")'
$ R/4.4.0/bin/Rscript -e 'cat("Hi!\n", file="|sed -e s/i/o/")'

For what it's worth, input pipes from less/more to R 4.4.0 do not hang, but are 
not always the same as before either. These are the same:

$ R/4.3.3/bin/Rscript -e 'con <- pipe("less --version", "r"); readLines(con); 
close(con)'
[1] "less (GNU regular expressions)" "Copyright (C) Mark Nudelman" ...
$ R/4.4.0/bin/Rscript -e 'con <- pipe("less --version", "r"); readLines(con); 
close(con)'
[1] "less (GNU regular expressions)" "Copyright (C) Mark Nudelman" ...

But these are not (again, on both Linux and MacOS):

$ R/4.3.3/bin/Rscript -e 'con <- pipe("less", "r"); readLines(con); close(con)'
[1] "Missing filename (\"less --help\" for help)"
$ R/4.4.0/bin/Rscript -e 'con <- pipe("less", "r"); readLines(con); close(con)'
character(0)


I did not see anything related here or in release notes or bugzilla. Is this a 
bug or something else?

Best,
--
Zafer


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] config.site settings for M3 Mac typo in manual?

2024-05-20 Thread Prof Brian Ripley via R-devel

On 20/05/2024 09:06, Duncan Murdoch wrote:
I've just upgraded to an M3 Mac laptop, and I'm working through getting 
the right configure settings to build R.


The Installation and Administration manual says to have this in 
config.site:


FFLAGS="-g -O2 -mmacos-version-min=11.0"
FCFLAGS="-g -O2 -mmacos-version-min=11.0"

but those give an error on my system, with it suggesting the FFLAGS and 
FCFLAGS version option should be -mmacosx-version-min=11.0.  I don't 
know if that's a typo or a change.


-mmacos-version-min= is the current Apple option.  However, the gfortran 
build recommended in the manual is quite old and this has apparently 
differed by GCC version (and is not documented in the 'man gfortran' I 
have).


I'll change the manual to mention both forms, and that it is only 
sometimes needed (not on my current setup).


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Output pipes to TTY hang

2024-05-20 Thread Zafer Barutcuoglu
Thank you, that makes sense. Not worth messing with those changes on my 
account, but since you asked, my actual use case was for an R script (or rather 
my package used by one) to display text (e.g. for --help) using the system 
PAGER, without writing temporary files for file.show() because modifying the 
file system just to show some help text doesn't seem right. No worries, easy 
enough for me to add a text.show() or general pipecat() in C, though cat(x, 
file="|less") did use to just work fine, too. Thanks again for clearing this up.

> On May 20, 2024, at 6:20 AM, Tomas Kalibera  wrote:
> 
> 
> On 5/20/24 07:36, Zafer Barutcuoglu wrote:
>> Hi,
>> 
>> I am seeing this on Linux as well as MacOS: Opening any output pipe from R 
>> 4.4.0 to TTY programs like "less"/"more" hangs, SIGINT-proof:
>>> $ R/4.4.0/bin/Rscript -e 'pipe("less", "w")'
>>> $ R/4.4.0/bin/Rscript -e 'cat("test", file="|less")
>>> $ R/4.4.0/bin/Rscript -e 'cat("test", file="|more")
>> R 4.3.3 and earlier have been working fine:
>>> $ R/4.3.3/bin/Rscript -e 'pipe("less", "w")'
>>> $ R/4.3.3/bin/Rscript -e 'cat("test", file="|less")
>>> $ R/4.3.3/bin/Rscript -e 'cat("test", file="|more")
> 
> I've tried the first example and it doesn't work for me even in R 4.3.3 on 
> Linux, so I can't easily test what changed the behavior for you, but it was 
> very likely a bugfix for PR#17764. Now the pipe() uses a special process 
> group to protect the processes (assumed to be background) from the terminal.
> 
> If you are interested in the details behind this, see the bug report 
> discussion or the blog post (below), and the source code.
> 
> A perhaps slightly over-simplified description is that tasks executed via 
> pipe() and (file="|") and system(wait="FALSE") are background tasks, which 
> should not be interruptible e.g. by Ctrl+C. This was fixed in R 4.4, which 
> required significant changes of the underlying implementation.
> 
> To support the very rare case when a task executed via system(wait="FALSE") 
> should receive signals from a console, because it is to logically implement 
> an interactive task using background tasks, there is now an argument 
> "receive.console.signals", which can be used to override this. This is used 
> by the R's parallel package to implement interactive computation on a cluster.
> 
> Your use case seems to be running an interactive task using pipe(). 
> Currently, there is no argument of pipe() to allow this as we didn't 
> anticipate anyone would actually be doing this - and, on my system, it 
> doesn't work even in R 4.3.3.
> 
> I assume the examples above are narrowed down cases to reproduce the change 
> in behavior. If there was a plausible, realistic example that would indicate 
> the need to add such argument to pipe(), it could be considered, but perhaps 
> it would be more natural to use 
> system(wait=FALSE,receive.console.signals=TRUE), anyway?
> 
> Best
> Tomas
> 
> https://blog.r-project.org/2023/05/23/not-interrupting-background-tasks-with-ctrl-c/index.html
> https://bugs.r-project.org/show_bug.cgi?id=17764
> 
>> 
>> R 4.4.0 also works fine with non-TTY output pipes:
>>> $ R/4.4.0/bin/Rscript -e 'pipe("cat", "w")'
>>> $ R/4.4.0/bin/Rscript -e 'cat("test", file="|cat")
>>> $ R/4.4.0/bin/Rscript -e 'cat("Hi!\n", file="|tr i o")'
>>> $ R/4.4.0/bin/Rscript -e 'cat("Hi!\n", file="|sed -e s/i/o/")'
>> For what it's worth, input pipes from less/more to R 4.4.0 do not hang, but 
>> are not always the same as before either. These are the same:
>>> $ R/4.3.3/bin/Rscript -e 'con <- pipe("less --version", "r"); 
>>> readLines(con); close(con)'
>>> [1] "less (GNU regular expressions)" "Copyright (C) Mark Nudelman" ...
>>> $ R/4.4.0/bin/Rscript -e 'con <- pipe("less --version", "r"); 
>>> readLines(con); close(con)'
>>> [1] "less (GNU regular expressions)" "Copyright (C) Mark Nudelman" ...
>> But these are not (again, on both Linux and MacOS):
>>> $ R/4.3.3/bin/Rscript -e 'con <- pipe("less", "r"); readLines(con); 
>>> close(con)'
>>> [1] "Missing filename (\"less --help\" for help)"
>>> $ R/4.4.0/bin/Rscript -e 'con <- pipe("less", "r"); readLines(con); 
>>> close(con)'
>>> character(0)
>> 
>> I did not see anything related here or in release notes or bugzilla. Is this 
>> a bug or something else?
>> 
>> Best,
>> --
>> Zafer
>> 
>> 
>>  [[alternative HTML version deleted]]
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel