From djberg96 at gmail.com Sat Mar 1 11:05:05 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 01 Mar 2008 09:05:05 -0700 Subject: [Win32utils-devel] Sapphire Message-ID: <47C97EB1.6020006@gmail.com> It has begun: http://www.sapphire-lang.org Regards, Dan From waynev at gmail.com Sat Mar 1 13:04:19 2008 From: waynev at gmail.com (Wayne Vucenic) Date: Sat, 1 Mar 2008 10:04:19 -0800 Subject: [Win32utils-devel] Sapphire In-Reply-To: <47C97EB1.6020006@gmail.com> References: <47C97EB1.6020006@gmail.com> Message-ID: <88c9ce410803011004n267b8da1jeb83af1d0f3ebd5d@mail.gmail.com> Hi Dan, Congratulations! I read through your docs, and this looks like a great start! Would you be up for removing "fork" from Kernel? IMHO, the standard library (and especially Kernel and Object) should only contain methods that have a good implementation (and I don't mean Cygwin) across _all_ supported platforms. I think it's fine for "fork" to be in some platform-specific library (like one named Posix), but the problem with it being in Kernel is that some programmers use it because it's there, and then are surprised that they've written non-portable code without realizing it. Best regards, Wayne On Sat, Mar 1, 2008 at 8:05 AM, Daniel Berger wrote: > It has begun: > > http://www.sapphire-lang.org > > Regards, > > Dan > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20080301/447c817e/attachment.html From djberg96 at gmail.com Sat Mar 1 16:39:50 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 01 Mar 2008 14:39:50 -0700 Subject: [Win32utils-devel] Sapphire In-Reply-To: <88c9ce410803011004n267b8da1jeb83af1d0f3ebd5d@mail.gmail.com> References: <47C97EB1.6020006@gmail.com> <88c9ce410803011004n267b8da1jeb83af1d0f3ebd5d@mail.gmail.com> Message-ID: <47C9CD26.9050801@gmail.com> Wayne Vucenic wrote: > Hi Dan, > > Congratulations! I read through your docs, and this looks like a great > start! Thanks! > Would you be up for removing "fork" from Kernel? IMHO, the standard > library (and especially Kernel and Object) should only contain methods > that have a good implementation (and I don't mean Cygwin) across _all_ > supported platforms. I'm absolutely going to remove fork from Kernel. There will be 'unix' and 'windows' libraries with their own namespace. So, if you want Kernel#fork, you'll have to require 'unix/kernel' explicitly. There will also be unix/file, windows/file, etc. > I think it's fine for "fork" to be in some platform-specific library > (like one named Posix), but the problem with it being in Kernel is that > some programmers use it because it's there, and then are surprised that > they've written non-portable code without realizing it. I agree. :) BTW, I've setup a sapphire-core mailing list. Visit here for options: http://sapphire-lang.org/mailman/listinfo/sapphire-core_sapphire-lang.org I've also setup an IRC channel, #sapphire, on Freenode. Regards, Dan From djberg96 at gmail.com Thu Mar 6 12:42:58 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 06 Mar 2008 10:42:58 -0700 Subject: [Win32utils-devel] Sapphire registration Message-ID: <47D02D22.6040008@gmail.com> Hey all, If you tried to register with the Sapphire project but were unsuccessful, please try again. I didn't have the email settings properly set, so I wasn't getting the approval notifications. In any case, I've changed the project settings so that you should be able to login immediately after registration, without having to wait for admin approval. Regards, Dan From phasis at gmail.com Thu Mar 6 19:58:25 2008 From: phasis at gmail.com (Heesob Park) Date: Fri, 7 Mar 2008 09:58:25 +0900 Subject: [Win32utils-devel] Sapphire registration In-Reply-To: <47D02D22.6040008@gmail.com> References: <47D02D22.6040008@gmail.com> Message-ID: Hi, 2008/3/7, Daniel Berger : > > Hey all, > > If you tried to register with the Sapphire project but were > unsuccessful, please try again. I didn't have the email settings > properly set, so I wasn't getting the approval notifications. > > In any case, I've changed the project settings so that you should be > able to login immediately after registration, without having to wait for > admin approval. In that case, please remove my pending account phasis68. I cannot register again for the error message : "login and email has already beed taken". Regards, > > Dan Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20080307/6c6860da/attachment.html From djberg96 at gmail.com Fri Mar 21 13:30:13 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 21 Mar 2008 11:30:13 -0600 Subject: [Win32utils-devel] Fwd: Is select() untrustworthy on Windows when used with handles from popen3? In-Reply-To: <006c01c8852a$8dd423b0$670aa8c0@wax> References: <006c01c8852a$8dd423b0$670aa8c0@wax> Message-ID: <6037b70c0803211030va512fa1s267dc89cf957fa15@mail.gmail.com> Any ideas? Dan ---------- Forwarded message ---------- From: Steve Shreeve Date: Thu, Mar 13, 2008 at 10:51 AM Subject: Is select() untrustworthy on Windows when used with handles from popen3? To: djberg96 at gmail.com Dan, Thanks for your work on the win32util modules. I've created an expect-like library that allows one to easily script interactions with non-GUI applications. Everything works great when connecting to the target system using a socket, or using PTY.spawn on Linux. On Windows, I get quite a bit of grief. Here's an example that has me confused: d:\>irb irb(main):001:0> require 'win32/open3' => true irb(main):002:0> i,o,e = Open3.popen3('date') => [#, #, #, 3164] irb(main):003:0> o.sysread(70) => "The current date is: Thu 03/13/2008 \nEnter the new date: (mm-dd-yy) " irb(main):004:0> select([o],nil,nil,1) => [[#], [], []] irb(main):005:0> o.sysread(1) # => here, it hangs... even though it *says* there's input to read ]== Since we hang at this spot, I'm sorta hosed... how can I trust select()? Steve == ps - I'd be happy to pay for your time to assist with this. From Daniel.Berger at qwest.com Mon Mar 24 11:32:04 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 24 Mar 2008 10:32:04 -0500 Subject: [Win32utils-devel] GetTempPath vs GetEnvironmentVariable vs getenv Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D30F2@ITOMAE2KM01.AD.QINTRA.COM> Hi all, I discovered some interesting quirks with regards to getting environment variable information on Windows. It's because 'TMP' is considered a system environment variable, which you can't change with SetEnvironmentVariable() according to the docs. I also noticed that GetTempPath() returns a full path if you set the value to a relative path. Here's a little program that demonstrates what I'm talking about: # Compare getenv/putenv, GetEnvironmentVariable/SetEnvironmentVariable require 'windows/api' include Windows GetTempPath = API.new('GetTempPath','LP','L') GetEnvironmentVariable = API.new('GetEnvironmentVariable', 'PPL', 'L') SetEnvironmentVariable = API.new('SetEnvironmentVariable', 'PP', 'B') Getenv = API.new('getenv', 'P', 'P', 'msvcrt') Putenv = API.new('_putenv', 'P', 'I', 'msvcrt') # ENV def get_env1(var) ENV[var] end # GetEnvironmentVariable def get_env2(var) buf = 0.chr * 260 GetEnvironmentVariable.call('TMP', buf, buf.length) buf.unpack('A*').first end # GetTempPath, which looks for 'TMP' first def get_env3 buf = 0.chr * 260 GetTempPath.call(buf.length, buf) buf.unpack('A*').first end # getenv() def get_env4(var) Getenv.call(var) end puts get_env1('TMP') # C:\DOCUME~1\djberge\LOCALS~1\Temp puts get_env2('TMP') # C:\DOCUME~1\djberge\LOCALS~1\Temp puts get_env3 # C:\DOCUME~1\djberge\LOCALS~1\Temp\ puts get_env4('TMP') # C:\DOCUME~1\djberge\LOCALS~1\Temp # Set 'TMP' using Ruby's ENV[]= ENV['TMP'] = "C:\\foo\\bar" puts "=" * 40 puts get_env1('TMP') # C:\foo\bar puts get_env2('TMP') # C:\foo\bar puts get_env3 # C:\foo\bar\ puts get_env4('TMP') # C:\DOCUME~1\djberge\LOCALS~1\Temp - oops # Set 'TMP' using SetEnvironmentVariable SetEnvironmentVariable.call('TMP', "C:\\zap") puts "=" * 40 puts get_env1('TMP') # C:\zap puts get_env2('TMP') # C:\zap puts get_env3 # C:\zap\ puts get_env4('TMP') # C:\DOCUME~1\djberge\LOCALS~1\Temp - oops # Set 'TMP' using putenv Putenv.call("TMP=C:\\blah") puts "=" * 40 puts get_env1('TMP') # C:\blah puts get_env2('TMP') # C:\blah puts get_env3 # C:\blah\ puts get_env4('TMP') # C:\blah - ah, there we go # Set 'TMP' to a relative path Putenv.call("TMP=dan") puts "=" * 40 puts get_env1('TMP') # dan puts get_env2('TMP') # dan puts get_env3 # C:\Documents and Settings\djberge\My Documents\dan - full puts get_env4('TMP') # dan The odd thing about TMP is that my shell value doesn't match the registry setting. The 'set' output shows: TMP=C:\DOCUME~1\djberge\LOCALS~1\Temp But the registry entry, under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment, is set to: C:\Temp Anyway, just thought I'd share. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20080324/bed374a4/attachment-0001.html From phasis at gmail.com Mon Mar 24 22:31:53 2008 From: phasis at gmail.com (Heesob Park) Date: Tue, 25 Mar 2008 11:31:53 +0900 Subject: [Win32utils-devel] GetTempPath vs GetEnvironmentVariable vs getenv In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB023D30F2@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB023D30F2@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: Hi, 2008/3/25, Berger, Daniel : > Hi all, > > I discovered some interesting quirks with regards to getting environment > variable information on Windows. It's because 'TMP' is considered a system > environment variable, which you can't change with SetEnvironmentVariable() > according to the docs. > I don't think so. 'TMP' can be changed with SetEnvironmentVariable(). But it affected only the current running process and child processes. Environment variable can be categorized into three levels: process, user and system level. You can change user and System environment variable persistently via registry setting. > The odd thing about TMP is that my shell value doesn't match the registry > setting. The 'set' output shows: > > TMP=C:\DOCUME~1\djberge\LOCALS~1\Temp > > But the registry entry, under > HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session > Manager\Environment, is set to: > > C:\Temp > User environment variables are stored in the Registry in the key: HKEY_CURRENT_USER\Environment System variables are found in the key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment Refer to http://vlaurie.com/computers2/Articles/environment.htm Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20080325/64b0e14d/attachment.html From djberg96 at gmail.com Thu Mar 27 07:47:17 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 27 Mar 2008 05:47:17 -0600 Subject: [Win32utils-devel] Fwd: CreateProcess function prototype In-Reply-To: <002701c88ff1$c8342510$660aa8c0@wax> References: <002701c88ff1$c8342510$660aa8c0@wax> Message-ID: <6037b70c0803270447y69fbd3e1g237676ca6f83f010@mail.gmail.com> Hm, I think he's write about params 3 and 4. Do we have to resort to the address for the ENV data structure? I can't remember now. Regards, Dan ---------- Forwarded message ---------- From: Steve Shreeve Date: Thu, Mar 27, 2008 at 4:03 AM Subject: CreateProcess function prototype To: Daniel Berger Dan, Also, the function prototype for CreateProcess on line 65 of windows\process.rb is incorrect. It should be: API.new('CreateProcess', 'PPPPLLLPPP', 'B') And, it might even be better to be: API.new('CreateProcess', 'PPPPLLPPPP', 'B') Thanks, Steve From phasis at gmail.com Thu Mar 27 08:31:43 2008 From: phasis at gmail.com (Park Heesob) Date: Thu, 27 Mar 2008 21:31:43 +0900 Subject: [Win32utils-devel] Fwd: CreateProcess function prototype References: <002701c88ff1$c8342510$660aa8c0@wax> <6037b70c0803270447y69fbd3e1g237676ca6f83f010@mail.gmail.com> Message-ID: <001201c89006$852d2130$9a7ba8c0@mycomputer> Hi, ----- Original Message ----- From: "Daniel Berger" To: "win32utils-devel" Sent: Thursday, March 27, 2008 8:47 PM Subject: [Win32utils-devel] Fwd: CreateProcess function prototype > Hm, I think he's write about params 3 and 4. Do we have to resort to > the address for the ENV data structure? I can't remember now. > I remember ENV is not just a pointer but a pointer of pointer. So it should be an address. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Mar 27 10:16:08 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 27 Mar 2008 09:16:08 -0500 Subject: [Win32utils-devel] Fwd: CreateProcess function prototype In-Reply-To: <001201c89006$852d2130$9a7ba8c0@mycomputer> References: <002701c88ff1$c8342510$660aa8c0@wax><6037b70c0803270447y69fbd3e1g237676ca6f83f010@mail.gmail.com> <001201c89006$852d2130$9a7ba8c0@mycomputer> Message-ID: <7524A45A1A5B264FA4809E2156496CFB023D3112@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Thursday, March 27, 2008 6:32 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Fwd: CreateProcess function prototype > > Hi, > ----- Original Message ----- > From: "Daniel Berger" > To: "win32utils-devel" > Sent: Thursday, March 27, 2008 8:47 PM > Subject: [Win32utils-devel] Fwd: CreateProcess function prototype > > > > Hm, I think he's write about params 3 and 4. Do we have to resort to > > the address for the ENV data structure? I can't remember now. > > > I remember ENV is not just a pointer but a pointer of pointer. > So it should be an address. Yes, that's right. It looks like I never caught the mistake in params 3 and 4 because I mistyped the hash keys in the Process.create method with regards to process_inherit and thread_inherit, so they were never actually being used. There were a couple of mistakes there, actually. Anyway, I'll fix win32-process and windows-pr tonight. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Thu Mar 27 19:03:07 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 27 Mar 2008 17:03:07 -0600 Subject: [Win32utils-devel] IO.socketpair addition -- very helpful! In-Reply-To: <006a01c89022$810f23c0$660aa8c0@wax> References: <006a01c89022$810f23c0$660aa8c0@wax> Message-ID: <6037b70c0803271603h12a69215h6aaa5be8e0d5e784@mail.gmail.com> Steve, Thanks for this. May I recommend joining the win32utils-devel mailing list? You would be most welcome with ideas like this! Regards, Dan On Thu, Mar 27, 2008 at 9:52 AM, Steve Shreeve wrote: > > > Dan, > > I had nearly pulled my hair out over the past week trying to figure out why > I couldn't spawn a process on Windows and communicate with it. A few things > I found out later: > > 1) The 'fork' implementation is totally gorked and should be renamed to > something other that 'fork'... it's more like 'clone_me_and_do_over()'. > 2) On Windows, pipes are essentially worthless because select() always says > there's data, which will take you into a black hole if you try to read it. > > I *did* figure out, however, that sockets actually behave quite nicely on > Windows. Also, I found your latest win32/process has some nice additions > (modulo the few tweakers we've been discussing recently). > > In order to create a fairly clean way to interact with subprocesses, I've > now got the code below. > > Let me know if this is helpful. > > Thanks, > > Steve > > == > > require 'socket' > > STDIN.sync = STDOUT.sync = STDERR.sync = true > > class IO > def self.socketpair(sync=true) > if RUBY_PLATFORM.include?('win32') > tcp = TCPServer.new('127.0.0.1', 0) > one = TCPSocket.new('127.0.0.1', tcp.addr[1]) > two = tcp.accept and tcp.close > else > one, two = UNIXSocket.socketpair > end > one.sync = two.sync = true if sync > [one, two] > end > > def self.spawn(cmd=nil) > io, child_io = IO.socketpair > > require 'win32/process' > child = Process.create( > 'app_name' => "cmd /k #{cmd}", # the "/k" keeps the process around > when it's done > 'process_inherit' => true, # not yet sure if this one is actually > needed > 'thread_inherit' => true, # not yet sure if this one is actually > needed > 'startup_info' => { > 'stdin' => child_io, > 'stdout' => child_io, > 'stderr' => File.open('nul', 'wb') # ignore STDERR, for now (what > about sync? close?) > } > ) > at_exit do > Process.TerminateProcess(child.process_handle, child.process_id) > Process.CloseHandle(child.process_handle) > end > child_io.close > > io > end > end > > io = IO.spawn('date') > > # communicate using "io" and control threads... >