[Gambas-user] Strange problem with running Shell on Fedora (code works in IDE but not in executable!!)

Tobias Boege taboege at ...626...
Sat Mar 30 13:39:58 CET 2013


On Sat, 30 Mar 2013, Beno?t Minisini wrote:
> Le 30/03/2013 13:14, Tobias Boege a ?crit :
> >>
> >> SHELL "a b c" ...
> >>
> >> is equivalent to:
> >>
> >> EXEC [ System.Shell, "-c", "a b c" ]
> >>
> >> with a call to setpgid(0,0) to create its own session like an
> >> independant shell.
> >>
> >> As for virtual terminal creation, they work both the same.
> >>
> >> - "For Input Output" => create a virtual terminal for the i/o of the
> >> child process, and get the i/o of the child process through it.
> >>
> >> - "For Read Write" => Just redirect the i/o of the child process to get
> >> them in the parent process.
> >>
> >> Can you try to replace "SHELL ..." by "EXEC [ System.Shell, "-c", ... ]"
> >> and tell me if it works better?
> >>
> >
> > Exec [System.Shell, "-c", "sudo -s id -u"] For Input Output
> >
> > It works!
> >
> > Regards,
> > Tobi
> >
> 
> So is it the setpgid() call that prevents sudo from finding the virtual 
> terminal? Strange...

Well, I spent the whole forenoon searching for a solution and setpgid() was
mentioned sometimes[0] when it was about acquiring a virtual terminal. Only
a session leader can change the virtual terminal (setsid()) but you *must
not* be a group leader (but you are by setpgid(0, 0)). This seems to be it,
indeed.

Regards,
Tobi

[0] http://blog.habets.pp.se/2009/03/Moving-a-process-to-another-terminal




More information about the User mailing list