Assuming I have 2 processes running. Is there any way for me to check which process terminates first during reboot/shutdown? From this link, it tells about appending boot to a file. Yet, I still don't know which process is terminated first between my 2 processes. Is there any way for me to do find out? Maybe a bash script or a .conf file. I'm applying this to CentOS, Redhat, Ubuntu, Solaris, HPUX.

1 Answer 1


This might not be accurate. But from what I've tested, we can try to play around with ps.

Write this file.


FILE *file;
char test[1024] = "/home/fikrie/testprogram.txt";
const char* command = "ps -eo pid,comm,lstart,etime,time,args | grep -E '<process that your monitoring> | <second process your monitoring' > /home/fikrie/runtime.txt;

void signal_callback_handler(int signum)
   file = fopen(test, "w");
   if(file != NULL)
     fprintf(file,"Caught signal %d\n",signum);

int main()
   signal(SIGINT, signal_callback_handler);
   signal(SIGHUP, signal_callback_handler);

   return EXIT_SUCCESS;

Compile, then make sure it run with the init. Then check if it starts. Kill your test process. Then check into the runtime.txt. You will see how long the process has been running. Take note of the time. Reboot and check the time again. Which ever process have the least time in between, that process is terminate first.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .