# A question about php_streams

- Thread: https://externals.io/message/14760
- Original archive: https://news-web.php.net/php.internals/14760
- Started by Mikey on 2005-02-09T17:03:51+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14760 — Mikey — 2005-02-09T17:03:51+00:00

URL: https://externals.io/message/14760#14760

Hi NG!

This is my first post to this NG and would like to prefix my question with
the following:

- I have read the manual, thoroughly. There is absolutely nothing in there
apart from how to call the funtion.

- I have searched the mailing list archives, to no avail.

- I have grep'ed the source, and have found one use of this function in
 `opendir()`, this has had limited usefulness.

- I have googled, and this had provided a great big list of manual mirrors
for my future reference ;-) Although I did find a page with a CVS commit on
it that had modified my example code.

I am trying to write a function that will recurse a directory, now the logic
of that is my bat and I am not seeking help with that. But I have tried
using the php_streams API to open the base directory with the following
code:

php_stream *base_dir = NULL;

php_stream_context *context = NULL;

TSRMLS_FETCH();

base_dir = php_stream_opendir (TMPL_G(template_dir),
ENFORCE_SAFE_MODE|REPORT_ERRORS, context);

However, everytime I try to run the module with this last line, I get a
segfault in apache. Now I am not very capable when it comes to Linux C
development and am only vaguely familiar with what gdb does, so I can't
really provide you with any other info than this.

Any help, pointers, etc would be greatly appreciated...

Mikey

---

## #14765 — Sara Golemon — 2005-02-09T17:50:42+00:00

URL: https://externals.io/message/14760#14765 · In reply to: #14760

> php_stream *base_dir = NULL;
>
> php_stream_context *context = NULL;
>
> TSRMLS_FETCH();
>
> base_dir = php_stream_opendir (TMPL_G(template_dir),
> ENFORCE_SAFE_MODE|REPORT_ERRORS, context);
>
That code is (on the surface at least) fine.

> However, everytime I try to run the module with this last line, I get a
> segfault in apache. Now I am not very capable when it comes to Linux C
> development and am only vaguely familiar with what gdb does, so I can't
> really provide you with any other info than this.
>
Here's some instructions on generating a backtrace:
http://bugs.php.net/bugs-generating-backtrace.php

Also, check to make sure that TMPL_G(template_dir) is (A) defined, and (B) 
points to a `NULL` terminated string in a memory segmet accessable to the 
process.  Of course, the backtrace will reveal that anyway.

-Sara
