Detecting rubyw

N

Nathaniel Talbott

Is there any way (on Windows) to detect if a script is running under
rubyw.exe, i.e. headless?

Thanks,


Nathaniel
Terralien, Inc.

<:((><
 
N

Nathaniel Talbott

Do you get an exception if you try puts? If so you could catch that.

Nope, no exception, and STDOUT.closed? returns false. Any other ideas?


Nathaniel
Terralien, Inc.

<:((><
 
N

nobu.nokada

Hi,

At Wed, 17 Nov 2004 12:02:12 +0900,
Nathaniel Talbott wrote in [ruby-talk:120600]:
Is there any way (on Windows) to detect if a script is running under
rubyw.exe, i.e. headless?

Can you open "CONIN$" and "CONOUT$" device files?
 
N

Nathaniel Talbott

At Wed, 17 Nov 2004 12:02:12 +0900,
Nathaniel Talbott wrote in [ruby-talk:120600]:
Is there any way (on Windows) to detect if a script is running under
rubyw.exe, i.e. headless?

Can you open "CONIN$" and "CONOUT$" device files?

I don't know... how would I do that? I don't think I've ever opened a
device file on Windows.


Nathaniel
Terralien, Inc.

<:((><
 
N

nobu.nokada

Hi,

At Wed, 17 Nov 2004 23:57:52 +0900,
Nathaniel Talbott wrote in [ruby-talk:120639]:
I don't know... how would I do that? I don't think I've ever opened a
device file on Windows.

Just open as well as ordinary files.

begin
open("CONIN$") {}
open("CONOUT$", "w") {}
have_console = true
rescue SystemCallError
have_console = false
end
 
N

Nathaniel Talbott

Nathaniel Talbott wrote in [ruby-talk:120639]:
I don't know... how would I do that? I don't think I've ever opened a
device file on Windows.

Just open as well as ordinary files.

begin
open("CONIN$") {}
open("CONOUT$", "w") {}
have_console = true
rescue SystemCallError
have_console = false
end

Excellent! Works great. Thanks a ton, Nobu.


Nathaniel
Terralien, Inc.

<:((><
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top