Search code examples
clinuxfirefoxforkexecl

How to correctly kill a program which is started using execl


I wrote a program which creates a child process using fork. In the child process I use execl which opens a local html page using firefox:

execl( "/usr/bin/firefox", "/usr/bin/firefox","/home/xyz/t/webpages/page1.html", (char*)NULL);

In the parent process after sleeping for 5 sec, i send a SIGTERM signal to the child process:

sleep(5);
kill(browser_pid,SIGTERM);

After compiling and executing everything works fine. But when I run the program for more than 5 iterations, firefox starts behaving erratically, and shows up a window to either reset firefox or open in safe mode : enter image description here

when I close the html page manually without sending the SIGTERM signal to the process and use the close button on the browser, it works flawlessly for any number of iterations.

My program is supposed to refresh the webpage every 5 seconds to show new content being written regularly. How can I do the same programatically ?


Solution

  • Deleting the ~/.mozilla folder resolved the issue.