[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: kmapnotify, LD_PRELOAD, (t)csh and aaarrgh! I'll die today! :-)
From:       Michael Matz <matz () ifh ! de>
Date:       2000-05-29 3:30:26
[Download RAW message or body]

Hi,

On Sun, 28 May 2000 tibirna@kde.org wrote:
> This automatically excludes non-X apps. Still, I'm sure that right now

Yes.

> notification attempts are done even when writing `bash` in the minicli

Yes too.

> (without checking on 'Terminal' in options). I know that in this case the
> notification times out after a while, but it's very plausible that in the
> meanwhile the user used and even closed that non-X app :-) Is it possible
> to detect if the app wants libX11 dlsyms?

That open a huge can of worms. You need to find out, if the called 'thing'
is a binary (after all it can be a shell expression). If its a simple
command, there is a chance its binary (it could also be an alias), but we
need to locate it. Well, even if we are very lucky and intelligent (which
we are ;)) and find the right binary in most cases, we would still need to
find out if its using X. Uhh. A can of worms on its own ;) We could parse
the "ldd" output. Bah. Its not even the same on each platform. On some its
not called "ldd". And after all its another extern process. Bah again. I'm
not too sure about an mechanism for loading and looking into the
binary. Well we could use libbfd. Don't even mention that ;) And of course
its unportable.

Short answer: no ;-)
We either have this notification on for every app, or not. (Well, we can
use regexps for well known programs like shells, to not expect some
notification)

> > source, and no binaries. Note also, that this is the _only_ way that works
> > for every app due to the way the dynamic linker works.
> 
> You mean the LD_PRELOAD way? I didn't finish my investigations. Isn't
> there any ldl API that does exactly the same *in the code*, without
> needing a SHELL for it?

With libdl (or in our case libltdl, which reminds me, that we have still
some code in kdelibs, that uses -ldl directly instead of libltdl) its
possible to load some DSOs and its symbols into its own process space. But
we need to modify the loading of _another_ binary. A completely separate
process. No chance to dlopen() anything. We can only go through the
system, and this is the dynamic loader.

> The remaining ones (and recapitulation) are:  :-)
> 
> - is there a way to detect that an app isn't linked to X11 (`ldd` in the
> API) so that kmapnotify doesn't start notification for nothing?

I whish there was a simple one. See above. If anybody has an idea, please
say so ;)

> - is there a way to implement functionality similar to LD_PRELOAD directly
> in the code?

No. Because LD_PRELOAD modifies another process, before it is even
started. You might think fork() and friends could bring a solution. After
all they are also starting another process. Unfortunately not.

> - is it ok to think about implementing the kmapnotfy function directly in
> KRun?

Of course it's OK ;) IIRC we had something like that before. It only
worked with KDE apps (or at least only a subset of all apps), and
generally faked the recognizing of an started app.


Ciao,
Michael.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic