You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mysterious Mose <we...@drdemento.com> on 2012/03/22 14:56:56 UTC

[users@httpd] accessing named pipe files from apache web server

Good morning,

    OK, I feel like an idiot, because this seems to me like a
straightforward thing, but not only can I not get it to work, I can't
seem to even find information about it. When I search for "apache" and
"named pipe" or "fifo" I keep getting tons of information about making
the logs pipe to a program.  I'm sure that's very useful, but it's not
what I'm interested in.

    I just want a plain named pipe as a file on the web server. I will
write information to the pipe, and when a web browser accesses the
pipe, it will read the information. Simple, right? But whenever I try
to access the pipe through the web, I get a 403 Forbidden error. Why?
The pipe is readable. I even tried making it 777 and still I get the
error.

    I thought maybe I needed to add something to httpd.conf or .htaccess
to get it to read from named pipes, similar to how there's a directive
telling it to follow symbolic links, but I haven't been able to find
anything.

    The only reference I was finally able to find was a November 2009 post
here from someone who sounded like he was doing the exact same thing,
but he was getting a blank page instead of a 403, so not sure why his
results were different. He was told he would have to make a
modification to the code to get it to work. Is this still the case, or
has apache been changed in the meantime?

    Why is this so difficult, and why aren't more people interested in
doing this? It seems like such a simple thing to do. If I create a
named pipe and write data to it, cat can get the data out, along with
many other programs. So why is apache different? Is it intentionally
trying to avoid reading data from named pipes, or is there some
low-level operating system issue that makes it difficult, which cat
has no problem with because it's part of the shell?

    Thank you for any insight!



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by Mysterious Mose <we...@drdemento.com>.
Good morning everyone,

    This thread was a month ago, but I just thought I should follow up in
case someone else runs into this later and has the same question.

    I was able to work around this with no real problem by just spawning
off a new process and letting the parent die. I for some reason
thought that wouldn't work because stdin and stdout would go somewhere
else, but of course stdin and stdout of a spawned process default to
the same as the parent process.

    I still find it confusing that a named pipe returns a 401 error, and
it would be interesting to know why that's the error returned, but I
was able to work around my particular problem, so I'm happy for now.
:-)

Thanks to everyone who replied,
MM

> Good morning Tom,
>
>     Thank you for your response! It's too bad things aren't as simple as I
> think they should be. :-)
>
>     I do understand how named pipes work in general on Unix, how you must
> have a reader and a writer for anything to happen.
>
>     If I create a named pipe and have no writer process, but then try to
> more or cat that file, it just hangs waiting for a writer. Once data
> goes in, the cat proceeds to dump it out as it should.
>
>     So my expectation was that apache would output nothing in response to
> the GET request until data was being written to the pipe. I figure it
> might time out after some period of nothing being written, but wasn't
> counting on that. But a 401 error seems really weird to me, and I get
> that whether or not there's a writer process on the named pipe.
>
>     I can accomplish what I want through CGI, but I was trying to work
> around a process time limit on a shared server. The CGI script gets
> killed if it runs too long, so my "brilliant" idea (so I thought!) was
> to use a named pipe instead, and have the CGI program spawn off a new
> process every so often to avoid being killed by the process time
> limit. So much for that idea. Sounds like it's either back to the
> drawing board, or on to a new host that doesn't impose this limit on
> CGI program runtimes. (I could understand a limit on CPU time, but
> their limit is on wall clock time, and the limit is only 2 or 3
> minutes, which seems unreasonable to me.)
>
> Thank You!
> MM
>
>> On Thu, Mar 22, 2012 at 1:56 PM, Mysterious Mose
>> <we...@drdemento.com> wrote:
>>> Good morning,
>>>
>>> [â¦]
>>>
>>>    Why is this so difficult, and why aren't more people interested in
>>> doing this? It seems like such a simple thing to do. If I create a
>>> named pipe and write data to it, cat can get the data out, along with
>>> many other programs. So why is apache different? Is it intentionally
>>> trying to avoid reading data from named pipes, or is there some
>>> low-level operating system issue that makes it difficult, which cat
>>> has no problem with because it's part of the shell?
>>>
>>>    Thank you for any insight!
>>>
>>
>> I think you are thinking about this too simply. If you mkfifo a fifo,
>> and then write data to it, you aren't actually writing data, as there
>> are no readers of the fifo yet; the writing process is blocked waiting
>> for the fifo to become writeable.
>>
>> Similarly, how should Apache deal with serving the fifo. Should it
>> open it for both read and writes, ie allowing multiple writes to the
>> fifo to appear in a single response, or should it open it just for
>> reads, and punt as soon as one write is received. What should it do
>> when there is no data to be read from the fifo?
>>
>> As you said, all these things are trivial, so I suggest you knock up a
>> CGI that treats FIFOs as you want them to be treated and returns the
>> data/times out as appropriate.
>>
>> Cheers
>>
>> Tom
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by Mysterious Mose <we...@drdemento.com>.
Good morning Tom,

    Thank you for your response! It's too bad things aren't as simple as I
think they should be. :-)

    I do understand how named pipes work in general on Unix, how you must
have a reader and a writer for anything to happen.

    If I create a named pipe and have no writer process, but then try to
more or cat that file, it just hangs waiting for a writer. Once data
goes in, the cat proceeds to dump it out as it should.

    So my expectation was that apache would output nothing in response to
the GET request until data was being written to the pipe. I figure it
might time out after some period of nothing being written, but wasn't
counting on that. But a 401 error seems really weird to me, and I get
that whether or not there's a writer process on the named pipe.

    I can accomplish what I want through CGI, but I was trying to work
around a process time limit on a shared server. The CGI script gets
killed if it runs too long, so my "brilliant" idea (so I thought!) was
to use a named pipe instead, and have the CGI program spawn off a new
process every so often to avoid being killed by the process time
limit. So much for that idea. Sounds like it's either back to the
drawing board, or on to a new host that doesn't impose this limit on
CGI program runtimes. (I could understand a limit on CPU time, but
their limit is on wall clock time, and the limit is only 2 or 3
minutes, which seems unreasonable to me.)

Thank You!
MM

> On Thu, Mar 22, 2012 at 1:56 PM, Mysterious Mose
> <we...@drdemento.com> wrote:
>> Good morning,
>>
>> [â¦]
>>
>>    Why is this so difficult, and why aren't more people interested in
>> doing this? It seems like such a simple thing to do. If I create a
>> named pipe and write data to it, cat can get the data out, along with
>> many other programs. So why is apache different? Is it intentionally
>> trying to avoid reading data from named pipes, or is there some
>> low-level operating system issue that makes it difficult, which cat
>> has no problem with because it's part of the shell?
>>
>>    Thank you for any insight!
>>
>
> I think you are thinking about this too simply. If you mkfifo a fifo,
> and then write data to it, you aren't actually writing data, as there
> are no readers of the fifo yet; the writing process is blocked waiting
> for the fifo to become writeable.
>
> Similarly, how should Apache deal with serving the fifo. Should it
> open it for both read and writes, ie allowing multiple writes to the
> fifo to appear in a single response, or should it open it just for
> reads, and punt as soon as one write is received. What should it do
> when there is no data to be read from the fifo?
>
> As you said, all these things are trivial, so I suggest you knock up a
> CGI that treats FIFOs as you want them to be treated and returns the
> data/times out as appropriate.
>
> Cheers
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by Tom Evans <te...@googlemail.com>.
On Thu, Mar 22, 2012 at 1:56 PM, Mysterious Mose
<we...@drdemento.com> wrote:
> Good morning,
>
> […]
>
>    Why is this so difficult, and why aren't more people interested in
> doing this? It seems like such a simple thing to do. If I create a
> named pipe and write data to it, cat can get the data out, along with
> many other programs. So why is apache different? Is it intentionally
> trying to avoid reading data from named pipes, or is there some
> low-level operating system issue that makes it difficult, which cat
> has no problem with because it's part of the shell?
>
>    Thank you for any insight!
>

I think you are thinking about this too simply. If you mkfifo a fifo,
and then write data to it, you aren't actually writing data, as there
are no readers of the fifo yet; the writing process is blocked waiting
for the fifo to become writeable.

Similarly, how should Apache deal with serving the fifo. Should it
open it for both read and writes, ie allowing multiple writes to the
fifo to appear in a single response, or should it open it just for
reads, and punt as soon as one write is received. What should it do
when there is no data to be read from the fifo?

As you said, all these things are trivial, so I suggest you knock up a
CGI that treats FIFOs as you want them to be treated and returns the
data/times out as appropriate.

Cheers

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by Mysterious Mose <we...@drdemento.com>.
Good morning Nick!

    Funny enough, you were the one who responded to the November 2009
thread that I saw earlier.

    How I'm trying to access it is just through a regular HTTP GET, like
it was any other file. I feel like named pipes behave like regular
files for the most part when you're in the shell, as long as there's a
writer process going to them. I can more them or whatever.

    I may investigate LogLevel and sendfile out of curiosity. I'm
disappointed that what I thought was easy isn't. :-(

Thank You!
MM

> On Thu, 22 Mar 2012 06:56:56 -0700
> "Mysterious Mose" <we...@drdemento.com> wrote:
>
>
>>     I just want a plain named pipe as a file on the web server.
>
> How are you trying to access it?  A named pipe isn't a regular
> file, and can't in general be treated as such.
>
> Not having tried it with apache, I don't know what to expect,
> but you could start by cranking up LogLevel and seeing what the
> error log tells me.  Also if you were trying to pretend it's
> a regular file then at the very least you'd need to disable sendfile.
>
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 22 Mar 2012 06:56:56 -0700
"Mysterious Mose" <we...@drdemento.com> wrote:


>     I just want a plain named pipe as a file on the web server.

How are you trying to access it?  A named pipe isn't a regular
file, and can't in general be treated as such.

Not having tried it with apache, I don't know what to expect,
but you could start by cranking up LogLevel and seeing what the
error log tells me.  Also if you were trying to pretend it's
a regular file then at the very least you'd need to disable sendfile.


-- 
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] accessing named pipe files from apache web server

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 3/22/2012 8:56 AM, Mysterious Mose wrote:
> 
>     I just want a plain named pipe as a file on the web server. I will
> write information to the pipe, and when a web browser accesses the
> pipe, it will read the information. Simple, right? But whenever I try
> to access the pipe through the web, I get a 403 Forbidden error. Why?
> The pipe is readable. I even tried making it 777 and still I get the
> error.

mod_proxy_scgi?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org