Implementing Linux 'shutdown' from within a GTK application

I have written an application on Raspbian using GTK 3. Overall, it has gone well, but now I need to shutdown the Pi from within the application. When the condition occurs, I run the following code:

        /* Kick off the shutdown task. */
        ShutdownProc= g_subprocess_new(G_SUBPROCESS_FLAGS_NONE,
        if (NULL == ShutdownProc) {
            g_warning ("Shutdown failed: %s", serror->message);

The intent is to kick off the shutdown task with time to allow the application to shut down cleanly. I don’t get any error message, but the system does not shut down as expected.

Have I missed something?

I found that changing the line specifying the shutdown command from ‘/usr/bin/shutdown’ to just ‘shutdown’ worked.

Apparently after issuing the sudo command, the full path is not required.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.