Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Hello!
GNU make is able to resolve dependencies between files and to compile only the necessary ones; my question is: can i interrupt make with ctrl-c and restart it later?
I'll explain better with an example:
I download app-x.y.z.tar.gz, unzip and untar, run ./configure, run make. While make is still compiling, let's suppose i have to reboot my computer; so i press ctrl-c while it is compiling appunit.c, and make stops. Later, a run make again. It doesn't compile the files it has already compiled, and restarts from the point where id had been stopped. Could appunit.o (result of compilation of appunit.c) be damaged?
It really is not different from compiling, modifying a source file and compiling again. That being said, why not just ./configure; make; make install; again to be 100% safe?
The original poster's question had to do with interrupting the make. If you're interrupting the make, you don't have to do the ./configure again later, because that's already run to completion. So just the make should be sufficient. His question was whether it would be safe, and my answer was Yes.
The frosting on the cake is that he won't recompile the modules that have already been completely compiled, thus saving time.
I don't know if it would be safe to simply continue. What if an object file was only partially written. You might want to run "make clean" and start over.
Whether you want to make clean and start over depends on how much time you would save by just continuing.
Suppose you don't make clean, but just continue, and a .o file (compiled, unlinked object) was only partially written. In that case, you will have an invalid .o file, and the linking phase will catch it during the next make. Suppose, instead of some .o file, the linked executable was only partially written. In that case, you will catch it the first time you try to run the program. If you'd save a lot of time by not starting over, it would be just as good to rely on these other ways of catching the error.
Thanks guys for your advice. My fear is that the object/executable may be corrupt. I've got no idea whether what i'm going to say is correct: if i ctrl-c just while the compiler is writing the object file to disk, shouldn't the kernel wait for the completion of the i/o operation before closing the process?
However, i think i can risk getting a bad file if it's worth it, i.e. if it would be too long to restart from the beginning... I can always recompile..!
Ctrl-c is an interrupt signal, not a kill -9. I would guess that when make receives the interrupt signal, make would finish something like writing the object/executable to disk before halting.
make has no special knowledge of what pass a compiler is in, or whether it's in the middle of writing an object file and should be allowed to complete. But I still think the ^C thing isn't terribly dangerous, for the reasons I said before.
Of course it is, I interrupt make all the time. The compiler doesn't leave half written files lying around (unless perhaps you kill -9 it), any partial files will either be completed or deleted. Naturally, though, if you're using make for some other purpose (it isn't just for compiling programs), with a program that doesn't clean up after itself, YMMV, but as far as gcc is concerned, there is no problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.