mikeizbicki / ucr-cs100

open source software construction course
Other
486 stars 407 forks source link

getlogin() returns NULL while running script #1397

Closed kevdev158 closed 9 years ago

kevdev158 commented 9 years ago

getlogin() works fine when I do ./a.out by itself, but when I run script and then ./a.out, getlogin() fails to return the login name until I exit the script in which case it works fine again.

mikeizbicki commented 9 years ago

In order for me to help, you need to provide enough information for me to reproduce the problem. In this case, that means giving the specific set of instructions that you run.

mikeizbicki commented 9 years ago

Also, it is always wrong to be using a.out to run your code. Why aren't you calling make and then running bin/rshell?

kevdev158 commented 9 years ago

I didn't really understand how to compile it with the makefile and the flags until just now. I got it working now though, but I have to use getpwuid() instead of getlogin().

Renee7547 commented 9 years ago

I have encountered the same problem as yours!!! And then I switched to use other's computer, it just went well. It seems that script can make many things different from the real running process!