You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And it's also weird if I call os.execute() in thread pool
-- threadTester.lualocalclassic=require'classic'localthreads=require'threads'threads.Threads.serialization('threads.sharedserialize')
localtds=require'tds'localthreadTester=classic.class('threadTester')
functionthreadTester:_init(atomic)
self.game=threads.Threads(1,
function ()
inner=atomicend)
self.atomic=atomicclassic.strict(self)
endfunctionthreadTester:play()
self.game:addjob(function ()
os.execute("sleep "..10)
end)
-- do some stuff outsidewhiletruedoifself.atomic:get() <0thenbreakendendendreturnthreadTester
-- test.lualocalthreads=require'threads'threads.Threads.serialization('threads.sharedserialize')
localtds=require'tds'localsignal=require'posix.signal'-- local ctrlpool = threads.Threads(1, function ()-- local tds = require 'tds'-- end)localatomic=tds.AtomicCounter()
atomic:set(1)
nThreads=4-- local ctrlPool = threads.Threads(1)-- ctrlPool:addjob(function ()localsignal=require'posix.signal'signal.signal(signal.SIGINT, function(signum)
print('\nSIGINT received')
print('Ex(c)iting')
atomic:set(-1)
end)
-- end)-- ctrlPool:synchronize()localgamePool=threads.Threads(nThreads, function ()
threadTester=require'threadTester'player=threadTester(atomic)
end)
fori=1, nThreadsdogamePool:addjob(function ()
print(string.format("begin in thread %d", __threadid))
localstatus, err=xpcall(player.play, debug.traceback, player)
ifnotstatusthenprint(string.format('%s', err))
os.exit(128)
endend)
endgamePool:synchronize()
gamePool:terminate()
here is the test result
> th test.lua
begin in thread 1
begin in thread 2
begin in thread 3
begin in thread 4
^C^C^C^C^C
SIGINT received
Ex(c)iting
I am now doing a project where I need to call a game to execute using os.execute() in each thread while collecting info... But I found that the signal handler is not functioning well...
The text was updated successfully, but these errors were encountered:
I found that it seems impossible to register a signal handler in thread pools, see code below
the running result is just ignore the signal...
But I do see some one setting the signal handler in threadpool, see https://github.com/Kaixhin/Atari/blob/master/async/AsyncMaster.lua from line 117
And it's also weird if I call
os.execute()
in thread poolhere is the test result
I am now doing a project where I need to call a game to execute using
os.execute()
in each thread while collecting info... But I found that the signal handler is not functioning well...The text was updated successfully, but these errors were encountered: