Results 1 to 2 of 2

Thread: Script hangs after unzip command executes when run from QProcess in SE Linux (RHEL 7)

  1. #1
    Join Date
    Apr 2018
    Posts
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Script hangs after unzip command executes when run from QProcess in SE Linux (RHEL 7)

    I am trying to get some help debugging an issue with a script hanging after an unzip command executes only when run from within a QProcess in an SE Linux (RHEL 7) Environment. I have discussed the issue with the other company involved in integrating my display application, several developers here and searched on unzip and QProcess. I am not QT developer - this other company is wrapping my application in a QProcess on their SE Linux OS. I posted a question about this on LinuxQuestions.org but they suggested I try here. Any ideas welcome. I don't have much to go on from the other company so looking for general QT information as well.

    I am providing my code to another company that is integrating it into a larger SE Linux operating system. On their OS, they have a Manager application that allows a maintainer user to select my display application and they then launch it from within a QProcess.

    The problem:

    Here is an unzip command being invoked by my application from a bash script:
    Qt Code:
    1. unzip -uo SEPV3_FINAL_IETM_Content_20171020_070315.zip -d $VIEWER_CONTENT
    To copy to clipboard, switch view to plain text mode 

    There are three unzip commands in total in the installation script but when it hangs, it doesn't get past the first (above). It appears to inflate all the content files (of which there are a large amount - at least 100).

    When it fails, we are never getting output from the if statement - which has either a fail or success. It just hangs and unzip never fully returns. It still shows as a process when do a ps -ef.

    When I run my application in a non-secure, non-wrapped method - just straight invocation from my startup script, there is no issue and the unzip works great with exact same code and scripts. Host and Target testing both passed on my side (using compatible RHEL 7 OS - but as root and not SE Linux). Going to same exact location on my target as it does on theirs.

    I don't have access to their code or environment for testing which makes it difficult. I have only the secure OS and my non SE Linux environment.
    I am just going by what they are telling me and have seen when integrating with them.

    ----------------------------------------------------
    More information on code related to problem:

    Here is what they sent me about their QProcess code:

    Reference they gave me:
    https://doc.qt.io/qt-5/qprocess.html[doc.qt.io]

    "This is how KM is calling all processes that it launches from icons on the screen:

    Qt Code:
    1. QProcess m_localProcess;
    2.  
    3. m_localProcess.kill();
    4. m_localProcess.close();
    5. m_localProcess.reset();
    6. m_localProcess.start(exePath,exeArgs);
    7. return (int)m_localProcess.pid();
    To copy to clipboard, switch view to plain text mode 

    When KM launches ADTA via QProcess, it gets lost in the various scripts, right after it unzips the .xml files it gets lost and goes nowhere. When the shell launches it, everything is fine. QProcess does not have all the elements that a shell needs. There is an ecosystem around monitoring the process that I need to keep in place, so I can’t just create a new way to launch your process. I’m looking into ways to set up the QProcess to be more like a shell environment, but I’m hoping you can simplify the scripts to launch ADTA and such to make it easier. Thanks!"

    KM is their Kiosk Manager application that controls my application. My application launch is one script called adta. So exePath is the path to my script (/var/opt/amas/adta). They verified the path matches what I am expecting. They said exeArgs is null. Obviously they only gave me a portion of their code. Not much to go on.

    Inside my script to launch application, I set up environment, etc and then make one call to start my main and log to a file as well as terminal:
    From bash script:
    Qt Code:
    1. ./msd_main |& tee /var/opt/amas/adta.log &
    To copy to clipboard, switch view to plain text mode 

    When the user puts in a content disk and selects option to upload it (after the OS reads the disk), I then launch a script that is stored with content on that disk.
    I make a system call from my application (C) code to launch that script (with cmd = name of script to launch)

    Qt Code:
    1. int target_compatibility_system (char *cmd)
    2. {
    3. pid_t pid;
    4. sigset_t set;
    5. int status;
    6.  
    7. sigemptyset(&set);
    8.  
    9. pid=fork();
    10. if (pid==0) {
    11. /* who's to say we know what's best for any launched process? */
    12. /* so unblock all signals before launching it. */
    13. pthread_sigmask(SIG_SETMASK, &set, NULL);
    14. execl("/bin/sh", "sh", "-p", "-c", cmd, NULL);
    15. } else {
    16. waitpid(pid, &status, 0);
    17. }
    18.  
    19. return(status);
    20. }
    To copy to clipboard, switch view to plain text mode 

    and that then calls the installation script (also on the disk)
    Qt Code:
    1. echo y | sh ./linux-installer.sh
    To copy to clipboard, switch view to plain text mode 

    It needs to input y for question asked by that script. I don't create the second script. It is created with content that is being loaded.

    The second script contains the unzip commands. I don't understand Qt enough to verify what he is staying about QProcess not having all the elements that a shell needs. What could they be missing? Is that even correct?

    When my co-worker created a simple QProcess based on what they gave us, to launch our application on host, it worked just as it did outside the QProcess. So it seems QProcess itself may not be the issue? So why isn't theirs working?

    When they launch our application from a gnome-terminal with SE Linux in permissive mode, it works just fine. So what is interfering with it inside the KM and QProcess? Not sure.

    Thanks for any advice/suggestions for what to try to do to fix/debug this further.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Script hangs after unzip command executes when run from QProcess in SE Linux (RHE

    Are you saying that your C program hangs at waitpid() [line 16] or that the kiosk program determines that your program has hung?

    If that is precisely how they call your script then the code at line 7 will return zero sometimes and a valid pid other times, depending on whether the asynchronous start happens before pid() is called. If they then do something like wait on the zero pid then they may perceive your script "hung".

Similar Threads

  1. Start a linux command and read its standard output using QProcess
    By arunkumaraymuo in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2015, 06:39
  2. Replies: 3
    Last Post: 31st July 2013, 02:32
  3. QProcess Shell Command (Linux) Elevate Privileges?
    By m3rlin in forum Qt Programming
    Replies: 13
    Last Post: 7th April 2013, 12:38
  4. Replies: 3
    Last Post: 23rd February 2011, 09:50
  5. Problem in Installing Qt SDK in Linux RHEL
    By c_srikanth1984 in forum Installation and Deployment
    Replies: 0
    Last Post: 7th April 2009, 08:14

Tags for this Thread

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.