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. Systemd shutdown, halt and reboot handling
Forum Updated to NodeBB v4.3 + New Features

Systemd shutdown, halt and reboot handling

Scheduled Pinned Locked Moved Solved General and Desktop
systemdpoweroffhaltreboot
19 Posts 3 Posters 2.6k Views 3 Watching
  • 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.
  • SGaistS SGaist

    That's rather something you should do at the system level i.e. dump a picture in your frame buffer after your application has closed.

    E Offline
    E Offline
    egor.utsov
    wrote on last edited by
    #6

    @SGaist By the events i meant poweroff, reboot, etc..

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #7

      I understood that. However as already written, that's not for your application to do because it's going to be stopped before the shutdown and reboot are going to happen. So if you trigger that from within your application then you can already show something but you still have to setup your system to show more information once your application is stopped because the frame buffer is likely going to be cleared at that point.

      If you don't handle the shutdown through your application then how is it happening ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply
      1
      • SGaistS SGaist

        I understood that. However as already written, that's not for your application to do because it's going to be stopped before the shutdown and reboot are going to happen. So if you trigger that from within your application then you can already show something but you still have to setup your system to show more information once your application is stopped because the frame buffer is likely going to be cleared at that point.

        If you don't handle the shutdown through your application then how is it happening ?

        E Offline
        E Offline
        egor.utsov
        wrote on last edited by
        #8

        @SGaist It can happen when user login through ssh and cissue systemctl poweroff for example

        kshegunovK 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Then as I already suggested, dump a picture in your frame buffer as part of the procedure. Your application will be killed quickly so it won't have the time to show anything special in that case.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • E egor.utsov

            @SGaist It can happen when user login through ssh and cissue systemctl poweroff for example

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by kshegunov
            #10

            In addition to what @SGaist wrote, there are limitations of what you can and can't do in signal handlers. Not everything is allowed.

            Read and abide by the Qt Code of Conduct

            E 1 Reply Last reply
            1
            • kshegunovK kshegunov

              In addition to what @SGaist wrote, there are limitations of what you can and can't do in signal handlers. Not everything is allowed.

              E Offline
              E Offline
              egor.utsov
              wrote on last edited by
              #11

              @kshegunov it is done not from signal handler, but from slot, connected to qsocketnotifier.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                Depending on what you do, you will get a SIGTERM and a SIGKILL right after. The later you can't interrupt nor try to do some more stuff.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                E 1 Reply Last reply
                0
                • SGaistS SGaist

                  Depending on what you do, you will get a SIGTERM and a SIGKILL right after. The later you can't interrupt nor try to do some more stuff.

                  E Offline
                  E Offline
                  egor.utsov
                  wrote on last edited by
                  #13

                  @SGaist but as i remember systemd documentation stated, that process have 60 seconds until sigkill

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    60 second per running process ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    E 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      60 second per running process ?

                      E Offline
                      E Offline
                      egor.utsov
                      wrote on last edited by egor.utsov
                      #15

                      @SGaist i guessed so. Saw it somewhere in docs.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        Can you find that information again ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        E 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Can you find that information again ?

                          E Offline
                          E Offline
                          egor.utsov
                          wrote on last edited by
                          #17

                          @SGaist No. Maybe i am mistaken. I found some info here: http://manpages.ubuntu.com/manpages/cosmic/en/man5/systemd.service.5.html

                          Check section about TimeoutStopSec=. On my system it is commented out, but here stated, that it is even 90 s. As i understand it is applied per-unit.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #18

                            Is your application started as a systemd service ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            E 1 Reply Last reply
                            0
                            • SGaistS SGaist

                              Is your application started as a systemd service ?

                              E Offline
                              E Offline
                              egor.utsov
                              wrote on last edited by
                              #19

                              @SGaist Yes, it is started as systemd service. Finally i found the reason, why it hangs. It is happened because I made blocking syscall from event loop. So this thread can be closed and marked as resolved. Appproach with QSocketNotifier and signalfd works.

                              1 Reply Last reply
                              2

                              • Login

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