This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [BUG?] run.exe and pdflatex


On Thu, 10 Jan 2008, Sven Köhler wrote:

> > Finally, you can look at the sources for run.exe (available via Cygwin
> > setup) and submit a patch (look at the first argument to
> > CreateProcess).
>
> Hmm. So indeed run seems to use the Windows-API to create the new
> rprocess. But that pdfetex knows, that is has been invoked by the name
> pdflatex, must be an internal cygwin thing. Because actually, when
> executing pdflatex from bash, cygwin must follow the symlink and then
> executed pdfetex.exe. Still, cygwin reports to pdfetex, that it was
> invoked with the command pdflatex.
>
> So i have no clue where to start here.

Try MSDN: <http://msdn2.microsoft.com/en-us/library/ms682425(VS.85).aspx>
(MSDN used to have much MUCH nicer URLs that actually contained the name
of the function the page described, but someone at Microsoft must've
decided that it made life too easy for the programmers).

> Actually, i wrote a small C program. And sure, it will not hide the
> console window, when startes. But it simply uses execve to start the
> program given in the parameter list:
>
> #include <stdio.h>
> #include <unistd.h>
>
> int main(int argc, char * argv[])
> {
>   if (argc < 2)
>   {
>     printf("you must give some parameters\n");
>     return 1;
>   }
>
>   int i = execve(argv[1], argv+1, NULL);
>
>   printf("execve failed: %i\n", i);
>   return 2;
> }
>
> I'm amazed, it even works. Anyway: after compiling it under cygwin and
> putting it to /bin/myrun.exe it's possible for me to successfully start
> pdflatex by using
>
>   c:\path\to\cygwin\bin\myrun.exe /usr/bin/pdflatex document.tex
>
> Hmm. I'm not sure, in which troubles i get by going this way.

No need to be amazed, once you've read the spec for execve and understood
the purpose of each parameter.

What you're essentially doing here is exactly what using "bash -c"
would've done, but without bash (kinda like that thing with Einstein
explaining radio).  In fact, you can do this with bash as well, by noting
that the arguments do not have to appear in quotes (try running the
following:

bash -c "exec /bin/echo \$@" some arguments here

and see what's printed; then read the bash man page for why this happens).

However, the above is *not* equivalent to using run.exe in that it will
not hide the console window (try it from a GUI).  To do this hiding,
run.exe *has* to use Win32 API like CreateProcess.  This isn't to say,
though, that the code cannot be fixed to do what you asked.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"That which is hateful to you, do not do to your neighbor.  That is the whole
Torah; the rest is commentary.  Go and study it." -- Rabbi Hillel
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]