On Sun, Mar 22, 2009 at 11:24, Alexander Hjalmarsson <hja...@sgh.se> wrote: > Hi! > > I want to get the path in a module I've created but I have some kind of > problem with it. It just works like the ordinary "pwd", and in 30% of the > cases it works like it should, but in the rest, it doesn't return anything > at all. > > if ((buffad = (char *)malloc((size_t)sizead)) != NULL) > ptrad = getcwd(buffad, (size_t)sizead); > > That is the call that is made, and buffed is a char *, as well as ptrad. > sizead is a long. > > Can this be a problem with permissions or something? The only cases that it > do work for is when theres a more advanced script that is called, such as a > forum or a blog (phpbb or wordpress in example). For normal, static html > pages, it just returns "/" instead of the real path. > > I've checked all the paths by writing each request to a file so I manually > can check them. I can't see why it should have anything to do with > permissions, but since it does work in some cases but not all, that's my > first thought. > > I would love all kind of help here! Feel free to ask anything, I'll try to > answer as good as I can! > > I've tried on all kind of forums, irc-networks and mailing lists with no > luck, but I guess this is the "right" place :)
Hello, getcwd returns the working directory of the apache process. It has nothing to do with modules. A process may work in any directory. If, after it starts running, the process performs a chdir(whatever_existing_dir) system call, all subsequent calls to getcwd will return whatever_existing_dir. You can see the working directory of a process with process ID x by running ls -l /proc/x/cwd Which path do you want to get? The path of the served file? S -- A: Because it reverses the logical flow of conversation. Q: Why is top-posting frowned upon? A: Top-posting. Q: What is the most annoying thing in e-mail?