We are doing a prototype of one device, where our central controller is running on RPi. Since we want it to automatically execute one application straight out of the box, without plugging anything in or triggering anything on command line, we run it in the bootscript in init.d.
The script works ok and the binary does too. Weird things happen when the file is saved when we quit (have a red button on GPIO) the binary and it saves the file (an XML file, we use pugixml). When we run this on the command line manually, logged in as user "pi", everything works. But when the script is automatically started, everything is of course run in sudo (which is the requirement anyway for the wirinPi library for GPIOs and serials) and works okay, but the xml file is saved to root ("/") with corrupted data. The path for file is okay and script works okay when triggered on command line manually.
Is there any workaround for this, i.e logging in as a pi as here In general, what is the root (no pun intended) cause of this?