Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Made a little c-program i want to start at boot and found out that i can do that through the rc.local script that runs once every time the computer boots. Say that i have a program called test in /home/user/Documents... what do i write rc.local? Know nothing about scripting and i didnt understand what i read when i googled it :/
Just add a line to rc.local containing the full path to the program you want to run. For example, if I want to run /home/djshaji/Documents/personal/new/c-programs/bin/hello_world, I would simply put the entire path to the program in rc.local. No need to do any scripting.
Just add a line to rc.local containing the full path to the program you want to run. For example, if I want to run /home/djshaji/Documents/personal/new/c-programs/bin/hello_world, I would simply put the entire path to the program in rc.local. No need to do any scripting.
And thats what i thought, but when i do that and run the script directly or do a reboot my program never starts. I know because if it starts the first thing it does is write "test" to a textfile, and it runs perfectly if i just run the program directly.
lol, ill just continue to answer myself so you know where im at. So ive found out that there is no problem with the rc.local script, just that i get segmentation fault. What is this? I can run the applikasjon from window, but not through rc.local
Okei, i was a bit quick to push the solved button on my other thread so sorry for spamming the forum :P (Really noob)
My program now starts during the boot through the use of rc.local, but its not still running when i login and check system monitor. My program is essentially an while-loop so it isnt quiting by itself.
OP: You've got to give a little more info, man! If you could share the code of your program, or at least to the point where it segfaults, that'd be great. In the meantime:
1. Where is the file to which your application writes "test"? if you fopen() a file that doesn't exist, the function would return a null pointer, and if you mess around with a null pointer, you're bound to get a SEGV
2. Drink Pepsi
3. Use full paths wherever possible in your program.
SIGSEGV in C is typically caused by overwriting the end of a char 'string' or an array.
A typical gotcha in re (1) is to forget about the '\0' reqd at the end of a string and write a 'normal' char over it, thus removing the EOS (end-of-string) marker that the C string fns rely on.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.