On 2023-08-16, Kenny McCormack <
[email protected]> wrote:
In article <fO7DM.428700$[email protected]>,
Scott Lurndal <[email protected]> wrote:
...
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html
11.1.3 The Controlling Terminal
"Each process of a session that has a controlling terminal
has the same controlling terminal"
"A terminal may be the controlling terminal for at most one session."
I believe there are security issues that would in general
prevent one from willy-nilly changing the controlling terminal
for an arbitrary process outside of the standard mechanisms like
setsid.
It looks like setsid(), followed by opening the desired terminal device,
may solve my problem. Yes, I get it that this doesn't allow you to do it
to an arbitrary process - it still has to be the process itself - but I
think I can live with that.
There are ways to make compiled programs do things!
Using LD_PRELOAD you can force an executable to load shared libraries
of your choice.
This is famously used for overriding functions. But it could also
introduce code that doesn't override anything.
A shared library can have global initialization code that is run
automatically, which you could use for manipulating the process'
environment. I think that would be called before main.
Your shared library could host a little server that listens for messages
of your own design, which make the process do whatever you want at any
point in its lifetime.
This is why Linux mostly doesn't suffer from viruses; that's
integrated as a feature.
P.S. No "XY problem" here, but the actual use case is way too complex to explain in a Usenet post.
n
Ah, XY problem. :)
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
[email protected]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)