I'm working on a uCLinux system and need to set a custom environment variable. I want the variable set early in the boot sequence so that started daemons can read it. I tried exporting the variable in the rcS startup script (before it launches the main startup scripts from /etc/rc.d/rcS.d/, this seems to work OK, but the login shell msh does not inherit the variable.

How do I configure the system so that basically all processes started see this new environment variable?

TY, Fred


not familiar with uCLinux itself so cannot be for sure of any specific place, but for things like this that you need for all the processes in linux, you should look into /etc/inittab or equivalent, where things are initialized for the system.

see if you have a /etc/default/init which is supposed to be used for this purpose.

I did some research and here is what the manual says, so /etc/rc is where you should add things, but look at it to see where is the appropriate place.

The init process, that automatically is started by the Kernel, first starts the script file /etc/rc and then uses /etc/inittab to start more processes, if some are defined there. By default the uCLinux-dist uses an empty inittab thus only /etc/rc is used to bring up the system.

  • or create one and see, as I am not sure what things got stripped out to make this distro really tiny (I think u is really mu for micro). – johnshen64 Apr 3 '12 at 20:13
  • I tried an /etc/default/init but it didn't get read. My current approach is to try and call an rc.default file early on in my rcS script. This does export the variables to daemons started by rcS OK, but annoyingly the shell msh does not have the variable set. Not sure how to solve that problem? – fred basset Apr 3 '12 at 21:18
  • do you see something like /etc/profile in your system? this is where login shells usually get its env. you can also try to find which environment variables are set and their values, and then try to grep recursively for them in /etc to find where they are set. – johnshen64 Apr 3 '12 at 21:23
  • did you try to edit /etc/rc? – johnshen64 Apr 3 '12 at 21:50
  • The default variables seem to be getting set in init.c. I was hoping to try and get this new env. variable set without having to modify any .c files. I tried creating an /etc/profile but that's not read either. – fred basset Apr 3 '12 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.