Hi guys, I just tried the die function inside main.c
It did not get called when I ctrl + c a running make process. Please help here. Also, fatal error handler in commands.C gets called multiple times. I believe it is getting called for each parallel make process the parent has invoked. Helpless now, need to find answer to below questions - 1) why the die() function is not getting called after a ctrl+c ? 2) why I am not able to printf anything in fatal error handler in commands.c ? I do printf but it doesn’t print on the screen. The stdout is gone? I tried running some command using system call and it ran means the control is definitely doing inside fatal error handler. 3) I basically want to know a way in which I should be able to execute a piece of code when main exits. Where should I put it? Just a note - the makefiles are not normal. They are trapping sigint using TRAP command in gnumakefile. Please help guys. Thanks in advance Nikhil On Fri, 6 May 2022 at 8:59 AM, nikhil jain <jainnikhi...@gmail.com> wrote: > Thanks Paul, I will utilize the die() function! I already changed make to > be distributed. Thanks to the remote-stub.c (stub). I filled it in with my > logic of distributing the compiles across machines. Working fine since > couple of years! :) > > Kaz, Yes you are right. > > Unfortunately, as per the requirement I need to print the status of make > through make only not by any wrapper calling make. Users usually dont use > wrappers and run make on command line. They are not aware of echo $? or > something like that to get the status. So, It would be useful If I just > print it for them on the stdout! > > Thanks guys for quick input. You dont know how much it will help me. > > > > On Fri, May 6, 2022 at 1:08 AM Kaz Kylheku <k...@kylheku.com> wrote: > >> On 2022-05-05 11:07, nikhil jain wrote: >> > Thanks Paul and Brian. >> > I understand Now it's not possible to find out if it was an incremental >> > build or a full build. >> > >> > What about the second question ? >> > >> > Before exiting make, I want to display the status of the build if it >> failed >> > or passed.. how do I do that ? >> > Does make store the exit code somewhere. >> >> Make certainly has a failed termination status for a failed build. >> Find the places where it is either returning from main or calling >> exit, and work backwards. >> >> You could just wrap make with a script: >> >> #!/bin/sh >> make "$@" && printf "build failed\n" >> >> >> > Re-Iterating - I want to display the status of the build before make >> exits. >> >> Why is that important; is something else going to happen between that >> diagnostic and the actual termination of make, such that the diagnostic >> must precede that event? >> >> > I do not want the shell which called make to fetch the status. This is a >> > requirement in which I need to tell the user that your build was >> completed >> > successfully or had issues. >> >> But another program, such as a script, obtaining the termination status of >> make is quite reliable. CI systems all over the world rely on it daily. >> >> I've seen entire toolchains wrapped in scripts (i.e. /path/to/gcc being >> a shell script which figures out sysroot parameters and calls the real >> compiler) >> and it made no difference to the build. >> >