Re: [BUG?] run.exe and pdflatex

2008-01-11 Thread Corinna Vinschen
On Jan 10 23:57, Igor Peshansky wrote:
 On Fri, 11 Jan 2008, Sven Köhler wrote:
  So the question is: who does all the checks (shebang, etc.)?
  - the execve implementation? (which is cygwin, right?)
  - the shell?
  - both?
 
 The shell.
   Igor

Cygwin's exec(3) calls have shebang magic builtin as described in
http://www.opengroup.org/onlinepubs/009695399/functions/exec.html


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: [BUG?] run.exe and pdflatex

2008-01-11 Thread Igor Peshansky
On Fri, 11 Jan 2008, Corinna Vinschen wrote:

 On Jan 10 23:57, Igor Peshansky wrote:
  On Fri, 11 Jan 2008, Sven Köhler wrote:
   So the question is: who does all the checks (shebang, etc.)?
   - the execve implementation? (which is cygwin, right?)
   - the shell?
   - both?
 
  The shell.
  Igor

 Cygwin's exec(3) calls have shebang magic builtin as described in
 http://www.opengroup.org/onlinepubs/009695399/functions/exec.html

Indeed.  Sorry, I missed the call to newargv.fixup in spawn_guts...

So, what was the reason, then, to remove si.wShowWindow = SW_HIDE from
spawn_guts in CVS?  Having it makes it much easier to fix run.exe
appropriately...
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-11 Thread Corinna Vinschen
On Jan 11 10:11, Igor Peshansky wrote:
 So, what was the reason, then, to remove si.wShowWindow = SW_HIDE from
 spawn_guts in CVS?  Having it makes it much easier to fix run.exe
 appropriately...

I would be somewhat surprised if this code would have any effect in
the trunk.  The code in question looked like this:

  if (!wincap.pty_needs_alloc_console ()  newargv.iscui  myself-ctty == -1)
{
  si.dwFlags |= STARTF_USESHOWWINDOW;
  si.wShowWindow = SW_HIDE;
}

Given that pty_needs_alloc_console() is false only on 9x, and is always
true on NT, the above code was only executed on 9x.  Since 1.7 dropped
9x support, the code could go away.  Shoot if I missed something.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: [BUG?] run.exe and pdflatex

2008-01-11 Thread Igor Peshansky
On Fri, 11 Jan 2008, Igor Peshansky wrote:

 On Fri, 11 Jan 2008, Corinna Vinschen wrote:

  On Jan 11 10:11, Igor Peshansky wrote:
   So, what was the reason, then, to remove si.wShowWindow = SW_HIDE from
   spawn_guts in CVS?  Having it makes it much easier to fix run.exe
   appropriately...
 
  I would be somewhat surprised if this code would have any effect in
  the trunk.  The code in question looked like this:
 
if (!wincap.pty_needs_alloc_console ()  newargv.iscui  myself-ctty 
  == -1)
  {
si.dwFlags |= STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
  }
 
  Given that pty_needs_alloc_console() is false only on 9x, and is always
  true on NT, the above code was only executed on 9x.  Since 1.7 dropped
  9x support, the code could go away.  Shoot if I missed something.

 You didn't, but I'm confused now.  Why would the code that uses execve to
 spawn a Cygwin console process NOT pop up a console window?  Even if the
 parent is compiled with -mwindows, if the app needs a console, one would
 be created, wouldn't it?
   Igor

Ugh.  ENOCOFFEE.  fhandler_console::need_invisible() takes care of it.  So
run.exe can be changed to use execve even in CVS HEAD.
Sorry for the noise.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/



Re: [BUG?] run.exe and pdflatex

2008-01-11 Thread Igor Peshansky
On Fri, 11 Jan 2008, Corinna Vinschen wrote:

 On Jan 11 10:11, Igor Peshansky wrote:
  So, what was the reason, then, to remove si.wShowWindow = SW_HIDE from
  spawn_guts in CVS?  Having it makes it much easier to fix run.exe
  appropriately...

 I would be somewhat surprised if this code would have any effect in
 the trunk.  The code in question looked like this:

   if (!wincap.pty_needs_alloc_console ()  newargv.iscui  myself-ctty == 
 -1)
 {
   si.dwFlags |= STARTF_USESHOWWINDOW;
   si.wShowWindow = SW_HIDE;
 }

 Given that pty_needs_alloc_console() is false only on 9x, and is always
 true on NT, the above code was only executed on 9x.  Since 1.7 dropped
 9x support, the code could go away.  Shoot if I missed something.

You didn't, but I'm confused now.  Why would the code that uses execve to
spawn a Cygwin console process NOT pop up a console window?  Even if the
parent is compiled with -mwindows, if the app needs a console, one would
be created, wouldn't it?
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/



[BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
Hi,

so i have a latex file here. pdflatex document.tex works. But run
pdflatex document.tex does not.

run.exe seems to be the best way to call cygwin application from
external windows apps. But the seems to be some difference from invoking
by a shell.

pdfetex seems to check the name by it has been invoked. When invoking
from the shell, it correctly finds out, that it has been invoked as
pdflatex but when invoked via run.exe, this check seems to lead to the
wrong result.

I guess, it's a bug of run.exe which might do more work, than it should
(like following symbolic links, or such stuff).


Regards,
  Sven



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
On Thu, 10 Jan 2008, Sven Köhler wrote:

 Hi,

 so i have a latex file here. pdflatex document.tex works. But run
 pdflatex document.tex does not.

 run.exe seems to be the best way to call cygwin application from
 external windows apps. But the seems to be some difference from invoking
 by a shell.

 pdfetex seems to check the name by it has been invoked. When invoking
 from the shell, it correctly finds out, that it has been invoked as
 pdflatex but when invoked via run.exe, this check seems to lead to the
 wrong result.

 I guess, it's a bug of run.exe which might do more work, than it should
 (like following symbolic links, or such stuff).

This is not really a bug in run.exe, because it was never documented to
work correctly with symlinks, and you'd get the same problem with any pure
Windows way of invoking pdflatex anyway.  But it is, arguably, a
deficiency in run.exe.

You can do a few things.  One is to pass an explicit parameter that tells
pdfetex to use pdflatex mode (i.e., -fmt pdflatex).  Another is to
invoke pdflatex via bash (i.e., run bash -c 'pdflatex ...').  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).
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 so i have a latex file here. pdflatex document.tex works. But run
 pdflatex document.tex does not.

 run.exe seems to be the best way to call cygwin application from
 external windows apps. But the seems to be some difference from invoking
 by a shell.

 pdfetex seems to check the name by it has been invoked. When invoking
 from the shell, it correctly finds out, that it has been invoked as
 pdflatex but when invoked via run.exe, this check seems to lead to the
 wrong result.

 I guess, it's a bug of run.exe which might do more work, than it should
 (like following symbolic links, or such stuff).
 
 This is not really a bug in run.exe, because it was never documented to
 work correctly with symlinks, and you'd get the same problem with any pure
 Windows way of invoking pdflatex anyway.  But it is, arguably, a
 deficiency in run.exe.

Hmm. I looked at the man pages, which says, that run's purpose is to
hide the console windows. Hmm. Maybe i'm kind of misusing the problem
right now.

But is there another easy way to execute cygwin programs from outside
cygwin? I think of symlinks, shell-scripts, perl-scripts, etc...
Using run.exe is quite handy for these cases.

 You can do a few things.  One is to pass an explicit parameter that tells
 pdfetex to use pdflatex mode (i.e., -fmt pdflatex).

That's maybe a good idea - but won't work for pslatex, since pslatex is
a shell script.

  Another is to
 invoke pdflatex via bash (i.e., run bash -c 'pdflatex ...').

Actually i HATE the bash -c command param1 param2 ... way of invoking
commands. It needs special escaping of white spaces and other special
characters, which usually nobody takes cares about causing unexpected
behaviour.
The way run.exe or sudo do it is much more elegant and transparent.

 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).

I'm not a unix-programmer unfortunatly. I'm not very familiar with the APIs.

Well, i will look into the source and try to find out, what run.exe is
actually doing. But CreateProcess sounds like a windows API call.
Wouldn't it be more elegant to use a cygwin-call similar to the one bash
uses?

But is run.exe linked against cygwin.dll?



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 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.


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.






signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
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/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
I just tried to run pslatex (which is a shell-script) with run.exe.

And actually, it won't run. There is a box saying Error: could not
start c:\cygwin\bin\pslatex. Well, it's not an exe-file. It's basically
a textfile to windows. Hence the error, i guess.


Now i wonder, if it's already safe or if it would be possible to use
cygwin API (for example execve) from run.exe. To fix all the issues,
run.exe really would have to use cygwin to start the command since only
that will resolv all the issues (analysing the shebang, following
symlinks, etc.).

Just modifying the CreateProcess won't do.
Or we would have to rewrite all the shebang/symlink stuff ourselves
which is error prone.



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 Now i wonder, if it's already safe or if it would be possible to use
 cygwin API (for example execve) from run.exe. To fix all the issues,
 run.exe really would have to use cygwin to start the command since only
 that will resolv all the issues (analysing the shebang, following
 symlinks, etc.).

OK, we cannot use execve, right? If we would, it would open yet another
console window will be opened for the program we'd like to exec, right?

So is there any cygwin call to analyse a path? A call, that simply
returns the program to execute, the parameters to pass, etc.?

It really would really be better pass all the work (finding shebang,
etc.) to cygwin so that it's consistent.



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 bash -c exec /bin/echo \$@ some arguments here
 
 and see what's printed; then read the bash man page for why this happens).

Oh, that possibility was new to me.

All i wonder, is why the some gets lost. Only arguments here is
printed. And actually i would like to argue, that $@ instead of $@
should be used.




signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Dirk Fassbender

Sven Köhler schrieb:

I just tried to run pslatex (which is a shell-script) with run.exe.

And actually, it won't run. There is a box saying Error: could not
start c:\cygwin\bin\pslatex. Well, it's not an exe-file. It's basically
a textfile to windows. Hence the error, i guess.


Now i wonder, if it's already safe or if it would be possible to use
cygwin API (for example execve) from run.exe. To fix all the issues,
run.exe really would have to use cygwin to start the command since only
that will resolv all the issues (analysing the shebang, following
symlinks, etc.).

Just modifying the CreateProcess won't do.
Or we would have to rewrite all the shebang/symlink stuff ourselves
which is error prone.



Check the cygstart utility.
I thing it works with  symbolic links.

Dirk

--
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/



Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Christopher Faylor
On Fri, Jan 11, 2008 at 12:13:59AM +0100, Sven K?hler wrote:
 bash -c exec /bin/echo \$@ some arguments here
 
 and see what's printed; then read the bash man page for why this happens).

Oh, that possibility was new to me.

All i wonder, is why the some gets lost. Only arguments here is
printed. And actually i would like to argue, that $@ instead of $@
should be used.

Because, as on linux, the arguments are taken to be argv[0 - 2].

bash -c exec /bin/echo \\$0\ \[EMAIL PROTECTED]

will get you all of the arguments.

cgf

--
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/



Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 Check the cygstart utility.
 I thing it works with  symbolic links.

Hmm. The cygstart utility is for starting application / opening files as
if they were double clicked in the explorer. So you can do:

cygstart my.pdf (will open acrobat reader)
cygstart pdflatex (will open a windows console windows which will
execute pdfetex, but not in pdflatex mode)
cygstart pslatex (will not work, since windows doesn't know how to start
a shell script)



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 However, the above is *not* equivalent to using run.exe in that it will
 not hide the console window (try it from a GUI).

Just tested it. It's not true.

I compiled my program with gcc -o /bin/myrun.exe -mwindows and
executed c:\cygwin\bin\myrun.exe /bin/sleep 60 from Windows Explorer.

No console window and sleep.exe runs.

Also c:\cygwin\bin\myrun.exe /bin/rxvt works as expected. No console
window.



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
On Fri, 11 Jan 2008, Sven Köhler wrote:

  Now i wonder, if it's already safe or if it would be possible to use
  cygwin API (for example execve) from run.exe. To fix all the issues,
  run.exe really would have to use cygwin to start the command since only
  that will resolv all the issues (analysing the shebang, following
  symlinks, etc.).

 OK, we cannot use execve, right?  If we would, it would open yet another
 console window will be opened for the program we'd like to exec, right?

Exactly.

 So is there any cygwin call to analyse a path? A call, that simply
 returns the program to execute, the parameters to pass, etc.?

 It really would really be better pass all the work (finding shebang,
 etc.) to cygwin so that it's consistent.

Yes, there is a well-known extensively tested way of handling shell
scripts, symlinks, etc.  It's called using a shell.  Just execve your
favorite shell (/bin/bash is most likely to be present in all installs,
and /bin/sh in Cygwin is the same as bash), and pass it the executable
path as an argument.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
On Thu, 10 Jan 2008, Christopher Faylor wrote:

 On Fri, Jan 11, 2008 at 12:13:59AM +0100, Sven K?hler wrote:
  bash -c exec /bin/echo \$@ some arguments here
 
  and see what's printed; then read the bash man page for why this
  happens).
 
 Oh, that possibility was new to me.
 
 All i wonder, is why the some gets lost. Only arguments here is
 printed. And actually i would like to argue, that $@ instead of $@
 should be used.

 Because, as on linux, the arguments are taken to be argv[0 - 2].

 bash -c exec /bin/echo \\$0\ \[EMAIL PROTECTED]

 will get you all of the arguments.

Or, in other words, read the bash man page for why this happens (in
particular, the part that talks about the -c argument). :-)
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/



Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
On Fri, 11 Jan 2008, Sven Köhler wrote:

  However, the above is *not* equivalent to using run.exe in that it will
  not hide the console window (try it from a GUI).

 Just tested it. It's not true.

 I compiled my program with gcc -o /bin/myrun.exe -mwindows and
 executed c:\cygwin\bin\myrun.exe /bin/sleep 60 from Windows Explorer.

 No console window and sleep.exe runs.

 Also c:\cygwin\bin\myrun.exe /bin/rxvt works as expected. No console
 window.

Actually, -mwindows just says that myrun.exe should not pop up a console
window.  The child process is a console app, and would have still popped
up a console.  Except that in Cygwin 1.5.x, spawnve always set wShowWindow
to SW_HIDE before calling CreateProcess if the parent didn't have a tty,
so, in effect, execve was doing the same as what run.exe was doing.

Now, in Cygwin 1.7.x (a.k.a. CVS HEAD), this is no longer the case (since
revision 1.243 of spawn.cc).  The comment simply says Drop
pty_needs_alloc_console check -- maybe Corinna can explain why it was
dropped.  So your program will not work as expected in the snapshots.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Sven Köhler
 Now, in Cygwin 1.7.x (a.k.a. CVS HEAD), this is no longer the case (since
 revision 1.243 of spawn.cc).  The comment simply says Drop
 pty_needs_alloc_console check -- maybe Corinna can explain why it was
 dropped.  So your program will not work as expected in the snapshots.

OK, thanks for the explanation.

But ... wouldn't that mean that any command executed would open a
console window?



In your other responses, you said, that using the shell is the most
preferrable way. Unfortunatly, i cannot use the shell. The method is
well understood. I could easily execute cygwin stuff by using:

bash -c exec \\$0\ \[EMAIL PROTECTED] program param1 param2 ...

The program from which i want to execute pdflatex/pslatex/etc. (which is
Texlipse, a Latex plugin for Eclipse) doesn't allow me to do so.


But aside from that: is the shell really the preferred way of doing
this? Doesn't the shell simply call execve again?
Following what you said, it should be best to call bash.exe from run.exe
to solve all the issues. So the question is: who does all the checks
(shebang, etc.)?
- the execve implementation? (which is cygwin, right?)
- the shell?
- both?



signature.asc
Description: OpenPGP digital signature


Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Igor Peshansky
On Fri, 11 Jan 2008, Sven Köhler wrote:

  Now, in Cygwin 1.7.x (a.k.a. CVS HEAD), this is no longer the case
  (since revision 1.243 of spawn.cc).  The comment simply says Drop
  pty_needs_alloc_console check -- maybe Corinna can explain why it was
  dropped.  So your program will not work as expected in the snapshots.

 OK, thanks for the explanation.

 But ... wouldn't that mean that any command executed would open a
 console window?

Yes, unless one is already allocated.  So, when you run cygwin.bat, that
opens the console, and this console is used for subsequent apps.  However,
if you tried to invoke a Cygwin application via Start-Run, you'd get a
console.

 In your other responses, you said, that using the shell is the most
 preferrable way. Unfortunatly, i cannot use the shell. The method is
 well understood. I could easily execute cygwin stuff by using:

 bash -c exec \\$0\ \[EMAIL PROTECTED] program param1 param2 ...

 The program from which i want to execute pdflatex/pslatex/etc. (which is
 Texlipse, a Latex plugin for Eclipse) doesn't allow me to do so.

Yet it would allow you to use run.exe in place of bash -c 'exec $0
$@'?  This is weird.

 But aside from that: is the shell really the preferred way of doing
 this? Doesn't the shell simply call execve again?

Not quite.  The shell will also set the right program name for
executables/symlinks, or interpret the shebang line and invoke the
interpreter via execve, rather than the script.

 Following what you said, it should be best to call bash.exe from run.exe
 to solve all the issues.

Indeed.  So, your invocation would be

run bash -c 'exec $0 $@' pdflatex your args

or something like that.


 So the question is: who does all the checks (shebang, etc.)?
 - the execve implementation? (which is cygwin, right?)
 - the shell?
 - both?

The shell.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
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/

Re: [BUG?] run.exe and pdflatex

2008-01-10 Thread Jeff
On Thu, 10 Jan 2008 21:47:08 +0100,
Sven Köhler skoehler[at]upb[dot]de wrote:

But is there another easy way to execute cygwin programs from outside
cygwin? I think of symlinks, shell-scripts, perl-scripts, etc...

The easiest or best depends partly upon what you use to provide
your console window. Do you run bash in a native Windows console? Do
you 'export CYGWIN=tty' to make this console window more POSIX-like?
Or, perhaps, maybe you use a terminal program. Cygwin RXVT can run in
native mode using the built-in W11 code, or it can be used with an X
server. If you have X11 installed, you can use xterm, and perhaps other
things. I read somewhere that some people use putty...

It also depends on which Windows subsystem you are using to launch your
Cygwin app. Are you adding registry entries to create Explorer context
menu commands and/or file type associations? Are you calling your
Cygwin app from a DOS batch file (and do you need the control to be
returned to your batch file once your Cygwin app completes)? Are you
calling it from a native Windows console mode app that accepts or
expects user-defined external apps for some functions? Or, perhaps, you
just want to create a desktop shortcut to your Cygwin app.

There has been a fair amount of discussion of this topic in the last
two months. I described my own solutions in
http://cygwin.com/ml/cygwin/2007-12/msg00506.html. And yes, some of
this discussion has been about shell quoting.

I'm not a unix-programmer unfortunatly. I'm not very familiar with the APIs.

Free documentation is available. The Single Unix Specification ver.2
(susv2) is downloadable at
http://www.opengroup.org/onlinepubs/007908775/download/. susv3 is
available at http://www.unix.org/single_unix_specification/; you must
register first, then you can navigate your way to the downloads page.

I also managed to find some Redhat linux manual pages (probably in an
RPM); section 2 of the manual also documents the APIs. I don't recall
where on RedHat's site I found them, I would have to dig for them
again.

These two resources, plus the Cygwin user's guide, should give you
everything you need.

Jeff

-- 
Sorry, my life is still in beta, and nowhere near stable enough for a
release.

--
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/