Results 1 to 3 of 3

Thread: QProcess to shutdown doesn't work

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QProcess to shutdown doesn't work

    I have this method:

    Qt Code:
    1. void MainWindow::shutdown()
    2. {
    3. //::gpioWrite(ENA_12V,PI_LOW);
    4. QProcess process;
    5. qDebug() << "Powering down the rpi" ;
    6. process.startDetached("sudo systemctl poweroff --no-block");
    7. }
    To copy to clipboard, switch view to plain text mode 

    It's running on an RPI (Bookworm 64 bit OS). The pi doesn't shutdown.

    If I run

    Qt Code:
    1. sudo systemctl poweroff --no-block
    To copy to clipboard, switch view to plain text mode 

    the rpi shuts down as expected.

    Why doesn't it work as a QProcess?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    502
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess to shutdown doesn't work

    Hi, does it work when you start your Qt program with sudo, and then only call systemctl without the sudo?
    Does it work if you use /sbin/poweroff?
    And lastly: does it work if you use system() instead of QProcess?

    Ginsengelf

  3. The following user says thank you to Ginsengelf for this useful post:

    davethomaspilot (31st January 2024)

  4. #3
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess to shutdown doesn't work

    Quote Originally Posted by Ginsengelf View Post
    Hi, ?
    Does it work if you use /sbin/poweroff?
    And lastly: does it work if you use system() instead of QProcess?

    Ginsengelf
    Thanks for the suggestions!

    does it work when you start your Qt program with sudo, and then only call systemctl without the sudo
    The application is already being run under sudo. I removed the sudo from the command executed, but still doesn't work.


    Does it work if you use /sbin/poweroff?
    Yes!

    Apparently the --noblock is not recognized.

    I got that from code I used back on Stretch. Without the --noblock, it sometimes took minutes before the rpi shut down.

    Thank you!

Similar Threads

  1. QProcess does not work in service
    By yasjera in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2014, 12:03
  2. QProcess doesn't start when memory consumption is too high
    By bibhukalyana in forum Qt Programming
    Replies: 7
    Last Post: 13th November 2013, 10:32
  3. Replies: 2
    Last Post: 3rd February 2011, 16:48
  4. Shortcut doesn't work
    By stella1016 in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2009, 03:37
  5. QProcess doesn't terminate
    By Bagstone in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2008, 01:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.