mercredi 11 mars 2015

getenv("HOME") returns "/root" with "sudo"


I'm writing a program on my Raspberry Pi that requires the function "getenv("HOME")" to locate "/home/pi".


However, since I'm using the "wiringPi" library that requires "sudo" to run, "getenv("HOME")" now returns "/root" as the HOME directory instead of "/home/pi".


Is there a way to locate "/home/pi" with "getenv("HOME")" while using "sudo" the run the program?


Any help will be appreciated. Thank you.




Aucun commentaire:

Enregistrer un commentaire