From: Lennon Day-Reynolds Date: 2004-08-23T06:52:59+09:00 Subject: Embedded Ruby and stdin I'm working on a simple wrapper which embeds the Ruby runtime and a script file into a single binary. The idea is to have something much like Exerb, but platform-independent (i.e., works anywhere Ruby does). It reads the size and offset of an included script from the last few bytes of the program binary, closes stdin and reopens it as a handle to argv[0], and seeks to the script offset before initializing Ruby. Everything goes fine until I call ruby_options(argv, argc), at which point I get an Errno::EINVAL exception. Does anyone with a little more experience working with the Ruby core have any suggestions for why this could be happening? I know that the filehandle is valid, since I do a number of I/O ops on it from C before passing control to Ruby. I know that I could just copy out the script data to another file, or eval it as a string, but there are potential problems with that: specifically, the fact that I'm trying to distribute binary files along with my Ruby program, which will be added to the __END__ section of the Ruby script before it is appended to the wrapper binary. Since these files will be quite large (50-150MB), I want to avoid copying them to another file, or loading them fully into RAM, if at all possible. Any ideas would be greatly appreciated. I can post code snippets first thing tomorrow morning once I'm back at work; I just wanted to see if anyone had any quick suggestions before that. -- Lennon rcoder.net