Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSharedMemory, Read / Write and Read Only.
Forum Updated to NodeBB v4.3 + New Features

QSharedMemory, Read / Write and Read Only.

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #7

    @J-Hilk, thank you, is there an example of this ?

    Kind Regards,
    Sy

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @SPlatten said in QSharedMemory, Read / Write and Read Only.:

      is there an example of this ?

      An example on how to pass an enum to QSharedMemory::attach()??

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #9

        As my understanding, the OP want the shared memory to only be ReadWrite to the application which create it, but ReadOnly to other applications which use this shared memory.
        So I thought he can't control all the applications. (Otherwise he can just tell these applications don't write.)
        But QSharedMemory::AccessMode is controlled by the application which calls QSharedMemory::attach().
        Let's say if I know the OP's shared memory key, then I can write an application to attach it by QSharedMemory::ReadWrite and overwrite his shared memory.
        So I thought that's not he wants.
        @SPlatten Is my understanding right?

        1 Reply Last reply
        1
        • SPlattenS SPlatten

          @J-Hilk, thank you, is there an example of this ?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #10

          @SPlatten
          Since shared memory may be handled differently by different OSes, and your request may not be doable, you should at least state which platform(s) you wish to support?

          SPlattenS 1 Reply Last reply
          0
          • JonBJ JonB

            @SPlatten
            Since shared memory may be handled differently by different OSes, and your request may not be doable, you should at least state which platform(s) you wish to support?

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #11

            @JonB , I want to support all platforms which is why I'm going to implement my own solution.

            Kind Regards,
            Sy

            J.HilkJ JonBJ 2 Replies Last reply
            0
            • SPlattenS SPlatten

              @JonB , I want to support all platforms which is why I'm going to implement my own solution.

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #12

              @SPlatten Do you know about the existence of QRemoteObjects ?
              It may be more suitable for your project

              https://doc.qt.io/qt-5/qtremoteobjects-index.html


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              SPlattenS 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @JonB , I want to support all platforms which is why I'm going to implement my own solution.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #13

                @SPlatten said in QSharedMemory, Read / Write and Read Only.:

                @JonB , I want to support all platforms which is why I'm going to implement my own solution.

                From what I have seen reading around (not very thorough) I don't think you can do this, certainly not on all platforms. It may be possible to export it read-only to child processes, but I don't see that for non-related processes? If it's not doable at the OS level, then QSharedMemory isn't going to be able to do it, for unrelated/non-Qt processes?

                When people start talking about, say, QRemoteObjects, I think you should clarify whether the other processes you want to share with are under your control/even written in Qt?

                • Do you have any control over the other processes?
                • Are these other processes run as sub-processes of your Qt process, or quite separately?
                SPlattenS 1 Reply Last reply
                0
                • JonBJ JonB

                  @SPlatten said in QSharedMemory, Read / Write and Read Only.:

                  @JonB , I want to support all platforms which is why I'm going to implement my own solution.

                  From what I have seen reading around (not very thorough) I don't think you can do this, certainly not on all platforms. It may be possible to export it read-only to child processes, but I don't see that for non-related processes? If it's not doable at the OS level, then QSharedMemory isn't going to be able to do it, for unrelated/non-Qt processes?

                  When people start talking about, say, QRemoteObjects, I think you should clarify whether the other processes you want to share with are under your control/even written in Qt?

                  • Do you have any control over the other processes?
                  • Are these other processes run as sub-processes of your Qt process, or quite separately?
                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #14

                  @JonB , I only want this solution for all processes in my solution, so for example the main process will create the framework for the memory map and then other 'modules' which provide additional functionality to the main process will add they're own additional memory maps. The idea being that each process that creates there own memory map has read and write access to the map, ever other process that is not the owner will have read only access.

                  For each memory map I will add flags to the front of the map which indicate when the memory has been updated.

                  Kind Regards,
                  Sy

                  JonBJ 1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @SPlatten Do you know about the existence of QRemoteObjects ?
                    It may be more suitable for your project

                    https://doc.qt.io/qt-5/qtremoteobjects-index.html

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #15

                    @J-Hilk No, I didn't but will look into it, thank you.

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @JonB , I only want this solution for all processes in my solution, so for example the main process will create the framework for the memory map and then other 'modules' which provide additional functionality to the main process will add they're own additional memory maps. The idea being that each process that creates there own memory map has read and write access to the map, ever other process that is not the owner will have read only access.

                      For each memory map I will add flags to the front of the map which indicate when the memory has been updated.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #16

                      @SPlatten
                      Then I think I would at least read the proposed solutuon in, say, https://stackoverflow.com/a/35003672/489865

                      So one thing you can do is shm_open(..., O_RDWR) in the parent and set up a writable mapping for the parent before closing the handle, then shm_open(..., O_RDONLY) to get a read-only file handle which you will pass to the children

                      I do not know how QSharedMemory operates, but if it indeed leverages this shm_... approach it may be relevant.

                      I will keep quiet now, as I know no more than this....

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved