Results 1 to 4 of 4

Thread: Possible for QSharedMemory to be shared by a QT application and a non-QT process?

  1. #1
    Join Date
    Jun 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Smile Possible for QSharedMemory to be shared by a QT application and a non-QT process?

    I'm a QT newbie so apologies if I'm missing something basic. I have a QApplication that calls an external executable. This executable will keep running infinitely, passing data to this QApplication through stdout, unless it's manually exited from by the user running it from console. This process does not wait for stdin while it is running (it's a simple c++ code that's running as an executable that has a while loop).

    I want to be able to modify this executable's behavior at runtime by being able to send some form of signal (any kind of signal, even a single byte. Not to be confused with QT's signal/slot) from the QApplication to the external process. I read about QT's IPC and I think QSharedMemory is the easiest way to achieve this. I cannot use any kind of pipes etc since the process is not waiting for stdin.

    Is it possible for there to be a QSharedMemory that is shared by the QApplication as a well as a process running externally that is not a QT application. If yes, are there any example someone can point me to; I tried to find some but couldn't. If not, what other options might work in my specific scenario?

    Thanks in advance

    EDIT: Just to be more clearer, I want to be able to modify the executable's behaviour by making it do other things, than what it's doing at a given time. This can probably be achieved by sending a number or a char that specifies something. The QApplication can close this executable through QProcess so that is not required to be done by sending any signal. If I use stdin of the executable to listen to the signal sent by the QApplication, will it interfere with the stdout of that executable which is being read by the QApplication? I presume not, since they're separate channels, but just wanted to be sure.
    Last edited by anshulvj; 25th June 2015 at 23:23.

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

    Default Re: Possible for QSharedMemory to be shared by a QT application and a non-QT process?

    How does the user running it from the console cause it to exit? Ctrl C?

    It strikes me that if you have access to change the other application to watched shared memory then you can make it listen on stdin for a magic drop-dead signal (that a user would not type by accident), watch for a specific file to appear signifying that it should close, or use QLocalSocket to talk to a named pipe/socket.

  3. #3
    Join Date
    Jun 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Possible for QSharedMemory to be shared by a QT application and a non-QT process?

    Either ctrl+C or ESC can exit the application. That is purely for debugging purposes. When both sides are perfected I won't need user input for anything on the c++ executable side. I will need the stdout of that process though, since my QApplication reads from stdout of that executable. I'm guessing if I use stdin of that executable to receive signals from the QApplication, it won't interfere with stdout of that executable since they're separate channels? I was just reading about that to make sure that is the case. I will look at QLocalSocket to see if I can use that to send signal to the stdin of the executable.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Possible for QSharedMemory to be shared by a QT application and a non-QT process?

    QSharedMemory is just an API around the system's shared memory facility, the memory controlled by that is not Qt specific.

    QLocalSocket is for system and even user local socket communication. It has nothing to do with stdin.

    To write to a child program's stdin, just use the respective QProcess API.

    Cheers,
    _

Similar Threads

  1. Depoyment Qt application as Shared Library
    By norrbotten68 in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2014, 00:13
  2. Shared Object In Qt and Linking to main application
    By Ashutosh2k1 in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2011, 10:36
  3. How to deploy application using shared library in Linux
    By cutie.monkey in forum Installation and Deployment
    Replies: 9
    Last Post: 21st January 2010, 18:41
  4. Application with shared library problem in linux
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2010, 07:20
  5. Replies: 3
    Last Post: 6th January 2010, 16:55

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.