[Gambas-bugtracker] Bug #2540: Gambas does not seem to be writing to same shared memory as local processes
bugtracker at gambaswiki.org
bugtracker at gambaswiki.org
Wed May 4 16:27:04 CEST 2022
http://gambaswiki.org/bugtracker/edit?object=BUG.2540&from=L21haW4-
Comment #3 by Brian G:
Looking at your code, Here is a possibly better way to look at it
Public shmaddr2 as pointer = 0
Public TheLogger as logger
Public Sub Form_Open()module...
Dim uidptr As Pointer
Dim protection As Integer
Dim visibility As Integer
Dim buf1 As String
Dim shm_size As Integer = 1048576
Dim shm_fd As Integer
Dim shm_addr As Pointer
Dim shm_id As String = "/SHM_SEG"
Dim vptr As Pointer = Null
Dim mmap_err As Long
protection = 3 ' PROT_READ | PROT_WRITE MAP_FIXED = 16
visibility = 2 ' MAP_SHARED(4) MAP_PRIVATE(2)
shm_fd = shm_open(shm_id, 2, 666) ' 2=read/write
If shm_fd == -1 Then
Message.Info("shm_open() failed!", " OK ")
Quit
Endif
' map shared Memory To process address space
shm_addr = mmap(0, shm_size, protection, visibility, shm_fd, 0)
mmap_err = shm_addr ' convert the pointer to a long
If mmap_err < 1 Then
Message.Info("mmap() failed!", " OK ")
Quit
Endif
shmaddr2 = shm_addr
'************ start the logger task ****************
TheLogger = new Logger
wait 0.001
' do what ever else
end
create a class of logger in your project
inherits task
while true
select case string@(shmaddr2)
case "Q"
quit 0
case "what ever"
.....
end select
end
More information about the Bugtracker
mailing list