[haiku-development] Re: VIm episodes: I. How to guess the name of parent process ...

  • From: "François Revol" <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 02 Apr 2009 01:38:33 +0200 CEST

The /dev/null trick doesn't work reliably when Tracker is started from
a Terminal btw...

> > Note that contents of argv[0] in case starting from Tracker is
> > equal to
> > "vim" both for "gvim" and "evim" links to vim binary.

Note here we depart from BeOS which was overriding argv[0] with the
full path to binary, now we do as POSIX asks, we do pass argv[0] (this
means = "-login" for login shells should now work). At least I think
it's been done.

> >
> > I have found that call
> >
> > ---------
> > team_info teamInfo;
> > get_team_info(getppid(), &teamInfo);
> > ---------
> >
> > fill the  teamInfo.args  with "/boot/beos/system/Tracker" in case
> > of
> > call from Tracker and "/bin/sh --login" for call from Terminal.
> > This
> > code snippet can help me to resolve the "Tracker run question" by
> > searching for "Tracker" sub-string. Is it correct enough?
>
> I guess it is -- you would check for the login shell parent though,
> so that
> this also works when starting from Deskbar or LaunchBox.

Or any other GUI app...

> > Are there better ways to handle this situation?
>
> Alternatively you could try to open "/dev/tty". This will only
> succeed, if
> the process has a controlling terminal, which every process started
> directly or indirectly from the Terminal has (unless it starts a new
> session). So this might be a bit too lax.

Same issue if Tracker is started form Terminal (although it's mostly
for debugging).

>
> > Is this correct at all, always start GUI Vim from Tracker?
>
> I guess so.
>
> > The only correct way I see now is installing the set of shell
> > scripts
> > (gvim, evim, rvim ...) with corresponding command line parameters.
> > Are
> > there any objections against it?
>
> Sound fine to me.

Actually...
What you can do instead is:

install as gvim binary instead
symlink others to it

and test if argv[0] == gvim

If someone starts gvim in Terminal he does mean gvim anyway... right ?

Another option is to install both binaries, but only assign the
resources to gvim, so only gvim is known to the mime db and then run.

I should probably do something alike with links, links -> links-g or
whatever.

François.

Other related posts: