Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QApplication handling unexpected X server shutdown?

QApplication handling unexpected X server shutdown?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    timwoj
    wrote on last edited by
    #1

    I have a Qt application that runs on a linux machine that displays UI windows on a Windows machine running an X server. There's a strong possibility that the users of my application will logout of Windows or kill the X server without quitting my application first.

    Is there a way to handle the unexpected shutdown of the X server, so that the application can gracefully shutdown, save stored data, etc? So far I've tried tying QApplication's aboutToQuit signal to a slot in my app, plus catching all exceptions in main. Neither worked as I expected.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      You should look into signal handling in your process. When the X Server process terminates all its child processes (including your application) are sent a signal (I don't know which one maybe SIGKILL or SIGTERM) that you can catch and gracefully handle if you want to, default behavior is to terminate the process.
      Note that you must not call Qt code from signal handlers (they interrupt anything running in the process). You can however post messages to QObjects (that is threadsafe!) and perform an asynchronous operation in the main thread that will eventually call QApplication::quit() and terminate the process.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        If with "unexpected shutdown" you mean a crash of the X server there's very little you can do. If it's simply saving your data when the user logs out, then just implement session management (see QSessionManager and the related docs).

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • T Offline
          T Offline
          timwoj
          wrote on last edited by
          #4

          rcari: I registered for every possible signal there is, and none of them are caught when the server shuts down.

          peppe: I mean if the user was to say, logout of Windows that's running an X server. It's not a crash on the X server's part.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved