On 09.10.2014 18:13, Dmitry Grigoriev wrote:
[...]
Now I want to show a confirmation yes-no dialog and get user's choice.
For now I know only one way - via external process, so I do this:
local pid = awful.util.spawn("Xdialog --yesno 'hello?' 7 34")
local x1, x2, status = posix.wait(pid)
if not x1 then error("posix.wait() failed for PID=" .. pid .. ": " ..
x2) end
local isYes = status == 0
The problem is that both spawn() and spawn_with_shell() create a child
of init process (PPID=1), not the child of awesome, so wait() always
gives me "No child processes" error. Is there any way to fix/overcome this?
No. awesome.spawn() (the function that awful.util.spawn() uses) tries to get as
far away from the child process as possible. There was a bug report where
awesome "crashed" when some special program was started. The reason was that
this program killed its whole process group on some events. Since then, I don't
think awesome has any business with being a parent of anything. Too risky.
I also tried os.exec() and posix.fork()+posix.exec(), both ways make WM
unresponsive: mouse cursor moves but no other reactions to my
mouse/keyboard commands.
How about io.popen()? I don't have Xdialog, but hopefully this represents its
behavior:
> return io.popen("(exit 1) && echo yes"):read("*a")
> return io.popen("(exit 0) && echo yes"):read("*a")
yes
This assumes that Xdialog creates an override_redirect window. While Xdialog is
running, awesome will freeze and stop doing anything until Xdialog exits. This
is also what would happen with your posix.wait().
Cheers,
Uli
--
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.