M***@dastardlyhq.com
2023-01-09 09:43:37 UTC
Has anyone ever used popen() with the r+ option on MacOS? Writing to the file
descriptor works fine (the output goes to the printer queue) but any attempt to
read the response from CUPS from the file descriptor simply hangs. eg:
if ((pfile = popen("lp","r+")))
{
... write data to printer ...
fgets(str,sizeof(str),pfile); <- hangs here
}
It also hangs if I try while(!feof(pfile)) or read(fileno(pfile),....)
lp is producing output and I can redirect to a file , eg popen("lp > myfile",..)
I assume this is some kind of buffer flush issue but I can't find anything on
google about it.
Thanks for any help.
descriptor works fine (the output goes to the printer queue) but any attempt to
read the response from CUPS from the file descriptor simply hangs. eg:
if ((pfile = popen("lp","r+")))
{
... write data to printer ...
fgets(str,sizeof(str),pfile); <- hangs here
}
It also hangs if I try while(!feof(pfile)) or read(fileno(pfile),....)
lp is producing output and I can redirect to a file , eg popen("lp > myfile",..)
I assume this is some kind of buffer flush issue but I can't find anything on
google about it.
Thanks for any help.