Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

envp PWD= #11

Closed
dacresni opened this issue Apr 28, 2011 · 7 comments
Closed

envp PWD= #11

dacresni opened this issue Apr 28, 2011 · 7 comments

Comments

@dacresni
Copy link

i would fork but I'd have nothing else to contribute. Coming undergraduate Operating Systems class, you look in the envp* dictionary. I forget how to get things out of dictionaries in C but the envp* dictionary is a parameter of your main function so, for example
int main(int argc,char *argv[],char *envp[])
printf("The environment is as follows:\n");
int a = 0;
while (envp[a] != NULL)
printf("\t%s\n", envp[a++]);
return 0;
the *envp pointer is a dictionary, so it should print out the entire environmental dictionary. where did u think bash was getting it?

@zackr
Copy link
Member

zackr commented Apr 29, 2011

I'm sorry, I don't understand. What is this about?

@dacresni
Copy link
Author

there is a line in the master branch of your os_posix.cpp file of apitrace and I was giving you a posix portable way to get the absolute path of the executable sense there's a comment requesting it on line 64. You just have to concatenate the PWD environmental variable with argv[0] of your argument vector to get the absolute path. (Instead of trying to read the proc file system) I was going to provide example code but i didn't want to forget. // http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe.

@zackr
Copy link
Member

zackr commented Apr 29, 2011

Ah, no, that's not what it is. The code in question is also in a library, which doesn't have the access the argv vector so we can't rely on it.

@zackr zackr closed this as completed Apr 29, 2011
@dacresni
Copy link
Author

but getenv should work, shouldn't it?

On Thu, Apr 28, 2011 at 10:40 PM, zackr <
reply@reply.github.com>wrote:

Ah, no, that's not what it is. The code in question is also in a library,
which doesn't have the access the argv vector so we can't rely on it.

Reply to this email directly or view it on GitHub:
#11 (comment)

"lalalalala! it's not broken because I can use it"

http://linux.slashdot.org/comments.pl?sid=194281&threshold=1&commentsort=0&mode=thread&cid=15927703

@zackr
Copy link
Member

zackr commented Apr 29, 2011

No, there's no env variable for the currently running process name.

@dacresni
Copy link
Author

dacresni commented May 4, 2011

have you tried it? That behavior seems contrary to posix. http://publib.boulder.ibm.com/infocenter/zos/v1r10/index.jsp?topic=/com.ibm.zos.r10.bpxbd00/getenv.htm
I just think it would be strange if it didn't work. This isn't just a GNU libC thing, its a posix thing.

@zackr
Copy link
Member

zackr commented May 4, 2011

Tried what? What behavior? That environment doesn't have a variable holding currently running process name? It never did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants