Results 1 to 13 of 13

Thread: QProcess / system call not working under linux. Why?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess / system call not working under linux. Why?

    Try:
    Qt Code:
    1. System_Call.start("dcmodify -m ...");
    2. if( System_Call.waitForStarted() == false ) {
    3. std::cerr << "error" << std::endl;
    4. }
    5. else {
    6. System_Call.waitForFinished();
    7. QByteArray X = System_Call.readAllStandardOutput();
    8. std::cerr << X.constData() << std::endl;
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Posts
    47
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess / system call not working under linux. Why?

    I tried it, but got nothing on the console....
    I still seem to get no results when I try to hard code even a single file (known to exist)... I tried startDetached and this seems to give *something* on the console... so it is a good start. Oddly enough, under linux, this does work for another section of code:

    Qt Code:
    1. QString AcquisitionBrowserWidget::Get_DICOM_Information(QString File_Name, QString Key_String_Value)
    2. {
    3. // Call 'dcmdump' from the DCMTK 3.5.4 toolkit (already in path), retrieve the result
    4. // from 'stdout'. Do a search for the specified key using a regular expression.
    5. QDir Directory(Target_File_Path);
    6. QFileInfoList Files;
    7. QProcess System_Call(this);
    8.  
    9. // Create the parameter list for the external call. Check operating system.
    10. QStringList Parameters;
    11. #ifdef Q_WS_WIN
    12. Parameters<<("\""+Target_File_Path+"\\"+File_Name+"\"");
    13. #else
    14. Parameters<<(Target_File_Path+"/"+File_Name);
    15. #endif
    16.  
    17. // Make the system call. Wait until execution is complete, then retrieve 'stdout' in a buffer.
    18. System_Call.start("dcmdump",Parameters);
    19. QString Standard_Output_Buffer;
    20. System_Call.waitForFinished();
    21. Standard_Output_Buffer = System_Call.readAllStandardOutput();
    22.  
    23. // Search the buffer for the key in the correct format. The key is assumed to be UNIQUE.
    24. QString RegExp = "([(]"+Key_String_Value+"[)])( [A-Z]{2} )([[])([ \\w,.:-]*)([]])";
    25. QRegExp Key_Pattern(RegExp);
    26. if(Key_Pattern.indexIn(Standard_Output_Buffer,0)>-1)
    27. {
    28. // The key was found, return it from the fourth regular expression grouping.
    29. //(*Output)<<Key_Pattern.cap(4)<<endl;
    30. return Key_Pattern.cap(4);
    31. }
    32. else
    33. {
    34. // The key was not found.
    35. //(*Output)<<RegExp<<endl; // Keep the fourth regular expression grouping.
    36. return KEY_NOT_FOUND;
    37. }
    38. }
    To copy to clipboard, switch view to plain text mode 

    Is voodo at work here? This is curious, and given the timing of this problem and my work deadline on monday... I am suspecting that dark forces are at work. This problem is very odd.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess / system call not working under linux. Why?

    Does "std::cerr << "something" << std::endl;" writes something on the console?

  4. #4
    Join Date
    Feb 2006
    Posts
    47
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess / system call not working under linux. Why?

    Yes it does.

    For a single file, no wildcard, when I use start() I get the following output to the console (there are multiple calls to this section of code):

    Qt Code:
    1. roetgen 102% something
    2. QProcess object destroyed while process is still running.
    3. something
    4. QProcess object destroyed while process is still running.
    5. something
    6. QProcess object destroyed while process is still running.
    7. something
    8. QProcess object destroyed while process is still running.
    9. something
    10. QProcess object destroyed while process is still running.
    11. something
    12. QProcess object destroyed while process is still running.
    To copy to clipboard, switch view to plain text mode 

    With startDetached(), I get this:

    Qt Code:
    1. roetgen 104% something
    2. something
    3. something
    4. something
    5.  
    6. something
    7.  
    8.  
    9. Tsomething
    10.  
    11.  
    12. There were 0 error(s)
    13.  
    14.  
    15. There were 0 error(s)
    16. here were 0 error(s)
    17.  
    18. There were 0 error(s)
    19.  
    20.  
    21.  
    22.  
    23. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/dicom-0000-muehlboeck_sebastien_20051126.085338_1_1.dcm
    24.  
    25. There were 1 error(s)
    26. There were 0 error(s)
    To copy to clipboard, switch view to plain text mode 

    A race condition is expected since repeated calls are happening on the same file.

    I suspect that Bojan may be on to something with the wildcards. If I insert the wildcard back and repeat the same experiment above, I get first (start()):

    Qt Code:
    1. roetgen 111% something
    2. QProcess object destroyed while process is still running.
    3. something
    4. QProcess object destroyed while process is still running.
    5. something
    6. QProcess object destroyed while process is still running.
    7. something
    8. QProcess object destroyed while process is still running.
    9. something
    10. QProcess object destroyed while process is still running.
    11. something
    12. QProcess object destroyed while process is still running.
    To copy to clipboard, switch view to plain text mode 




    ...and then for startDetached(), I get:

    Qt Code:
    1. roetgen 108% something
    2. something
    3. something
    4.  
    5.  
    6. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    7.  
    8. There were 1 error(s)
    9. something
    10. something
    11. something
    12.  
    13.  
    14. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    15.  
    16. There were 1 error(s)
    17.  
    18.  
    19. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    20.  
    21. There were 1 error(s)
    22.  
    23.  
    24. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    25.  
    26. There were 1 error(s)
    27.  
    28.  
    29.  
    30. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    31.  
    32. There were 1 error(s)
    33.  
    34. error: unable to load file /export/data/jsalik/DICOM_DB/PENDING/SEBASTIAN_HEAD_4/*.*
    35.  
    36. There were 1 error(s)
    To copy to clipboard, switch view to plain text mode 


    The solution here has much to do with the way the operating systems deal with external processes and how they process wildcards as parameters. Does this sound reasonable?

    JS

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess / system call not working under linux. Why?

    Quote Originally Posted by johnny_sparx
    QProcess object destroyed while process is still running.
    Maybe QProcess::waitForFinished() timeout is too small? What does QProcess::error() return?

    The solution here has much to do with the way the operating systems deal with external processes and how they process wildcards as parameters. Does this sound reasonable?
    Yes, under Unices wildcards won't be processed.

  6. The following 2 users say thank you to jacek for this useful post:

    johnny_sparx (13th March 2006), ucntcme (14th March 2006)

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
  •  
Qt is a trademark of The Qt Company.