Results 1 to 6 of 6

Thread: Questions about kill() and start() of QProcess

  1. #1
    Join Date
    Jul 2006
    Posts
    42
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question Questions about kill() and start() of QProcess

    I tried to start an external process (I named it: PEX) from another Qt (version 3.x) application (I named it: PGUI). The PGUI runs 24/7/365 and the process PEX needs to be ran as long as the PGUI is running. In PGUI, I use the start() of QProcess to start the PEX.

    The PGUI also can kill (kill()) the PEX and re-start PEX many times at the beginning when the PGUI start to run. It works as designed. But, after a few days (or a few hours, it varied,) the PEX stops working. (the PEX is still in the process list.) Then, I stop the PEX by using QProcess kill(), sometimes the PEX can be out of process list, sometimes not. (at this moment, the only way I can get rid of the process is manually remove it by using shell command "kill" or "kill -kill") It seems that the PGUI loses the control of the PEX. That is the first problem. The kill() of the QProcess does not work all the time.

    The second problem is, then, the PGUI can no longer start another PEX (the PEX is designed to run multiple instance). I use processIdentifier() to retrieve the PID, and, as expected, the PID is -1.

    Can anyone help to solve the problems?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Questions about kill() and start() of QProcess

    The application probably freezes, crashes or stops working in some other way. First thing to do should be to make sure it runs correctly.

  3. #3
    Join Date
    Jul 2006
    Posts
    42
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Questions about kill() and start() of QProcess

    The application (PGUI) is still running. Other than the QProcess can not kill or start another process (PEX), everything else are running as expected.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Questions about kill() and start() of QProcess

    I meant that the backend freezes or crashes, that's why you can't stop or restart it. Can you try using some debug output from the console app and maybe also intercept unix SIGTERM signal to see if it's received and processed.

  5. #5
    Join Date
    Jul 2006
    Posts
    42
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Questions about kill() and start() of QProcess

    I am very sure that the backend process is "crashed" or "freezed". and that is why I try to use kill() of QProcess to kill it.

    Q1: I assumed that when the process is first created by using QProcess, the main program, in my case PGUI, got a "handle" (sorry, it is a "Windows" term, I do not know how the Linux calls it.) When I used this "Handle" to start an external process (PEX), shouldn't the handle know all the info of this external process? Includes the PID? (sure it knows because I can ask for the PID, and I can get it.) So, when the backend application dies, kill() of the QProcess should have just killed the PID, shouldn't it?

    Q2: OK, the backend application is dead. QProcess can not kill it. I kill it by using shell's command. How come I still can not start a new backend application? ( create a new process to start the backend application.)

    Q3: I am not sure how to "try using some debug output from the console app" since the backend application has no "Windows" when it is started by QProcess.

    Q4: I am not familiar with "intercept unix SIGTERM signal" Would you please detail it more?

    Thanks for your reply!!!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Questions about kill() and start() of QProcess

    Quote Originally Posted by mp33919 View Post
    I am very sure that the backend process is "crashed" or "freezed". and that is why I try to use kill() of QProcess to kill it.
    Maybe you should try to determine why it dies first?

    So, when the backend application dies, kill() of the QProcess should have just killed the PID, shouldn't it?
    Yes, but "kill" can mean many things. If a process crashed, killing it won't do anything because it is already not working. If it froze, killing it with signals other than SIGKILL might be ineffective as well.

    Q2: OK, the backend application is dead. QProcess can not kill it. I kill it by using shell's command. How come I still can not start a new backend application? ( create a new process to start the backend application.)
    My guess is that the backend has an exclusive lock on some resource and when you're trying to access that resource from another instance of the application it fails and the app dies or something like that.

    Q3: I am not sure how to "try using some debug output from the console app" since the backend application has no "Windows" when it is started by QProcess.
    "Output" doesn't necessarily mean "screen output" - you can write to a file or even to stdout and then retrieve that data from the QProcess object. Then you can do whatever you want with it.

    Q4: I am not familiar with "intercept unix SIGTERM signal" Would you please detail it more?
    man signal
    man sigaction

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.