Recommended way for a Linux app to inform user of an exception
10
votes
5
answers
1763
views
In this context, an 'exception' is an undesirable scenario, which could be: a code-level signal (like SIGSEGV), incorrect ways of launching an app (like launching a command-line app as a daemon) etc.
For a command-line app, the way to report exceptions to the user is by outputting to stderr - no doubts here.
For a GUI app using GTK, an error window displayed using GTK's [MessageDialog](https://docs.gtk.org/gtk3/class.MessageDialog.html) can be used. But what if the
MessageDialog
fails, either due to unstable state of the app (SIGSEGV or SIGBUS may not have any recovery) or the API itself failed... in that case, how can a GUI app inform the user?
Finally, a daemon... A daemon needs to inform user either due to a code-level exception (signals) or an external exception - user could launch a command-line app as a daemon, which is not a desirable way of launch, since a command-line app would've exited after its task is completed, but a daemon is expected to run for a long time. The command-line app could detect it was launched as a daemon and inform the user that it was launched incorrectly, but output to stderr does nothing here... how can a command-line app launched as daemon inform user that it was launched incorrectly?
The main question is, how can each of these apps communicate with the user in the above mentioned scenarios? What is Linux's recommendation?
PS: I'm new to Linux and app development in Linux.
Asked by NightFuryLxD
(201 rep)
May 24, 2025, 02:18 PM
Last activity: May 27, 2025, 10:38 AM
Last activity: May 27, 2025, 10:38 AM