Professional Web Applications Themes

spawning processes from Ruby/TK - Ruby

Hi, I need to launch an external process from a Tk app. I have a list-box of file names that should be processes as follows: listbox.bind('Double-Button-1') { file = listbox.get(listbox.curselection) errors += `#{cmd % [file]}` } This causes a repeated error message: C:\bin\cygwin\bin\ruby.exe: *** unable to remap C:\bin\cygwin\bin\tk84.dll to same address as parent(0x8C40000) != 0x8C50000 4274332 [main] ruby 2584 sync_with_child: child 3260(0x280) died before initialization with status code 0x1 4274659 [main] ruby 2584 sync_with_child: *** child state child loading dlls So do 'system' and 'IO.popen' calls. 'exec' works, but of course terminates the app. Any ideas what's wrong? Cheers, Assaph...

  1. #1

    Default spawning processes from Ruby/TK

    Hi,

    I need to launch an external process from a Tk app. I have a list-box of
    file names that should be processes as follows:

    listbox.bind('Double-Button-1') {
    file = listbox.get(listbox.curselection)
    errors += `#{cmd % [file]}`
    }

    This causes a repeated error message:

    C:\bin\cygwin\bin\ruby.exe: *** unable to remap
    C:\bin\cygwin\bin\tk84.dll to same address as parent(0x8C40000) !=
    0x8C50000
    4274332 [main] ruby 2584 sync_with_child: child 3260(0x280) died before
    initialization with status code 0x1
    4274659 [main] ruby 2584 sync_with_child: *** child state child loading
    dlls

    So do 'system' and 'IO.popen' calls. 'exec' works, but of course
    terminates the app.
    Any ideas what's wrong?

    Cheers,
    Assaph




    Mehr, Guest

  2. #2

    Default Re: spawning processes from Ruby/TK

    Hi,

    From: "Mehr, Assaph (Assaph)" <com>
    Subject: spawning processes from Ruby/TK
    Date: Tue, 10 Feb 2004 11:22:01 +0900
    Message-ID: <global.avaya.com> 

    Which version of Ruby do you use?
    If you use 1.6.x, the problem maybe fixed on more recent versions.
    On my linux environment, 1.6.7 freezes and CVS Head completes properly.
    --
    Hidetoshi NAGAI (kyutech.ac.jp)


    Hidetoshi Guest

  3. #3

    Default Re: spawning processes from Ruby/TK

    > I need to launch an external process from a Tk app. I have a list-box of 

    "unable to remap" is probably cygwin's problem which has solution on its own

    searching in cygwin gives result and here is "c" program for "rebase"

    =================
    /*
    * Copyright (c) 2001 Jason Tishler
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * as published by the Free Software Foundation; either version 2
    * of the License, or (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.
    *
    * $Id: rebase.cc,v 1.5 2001/12/18 20:21:19 jtishler Exp $
    */

    #include <iostream>
    #include <sstream>
    #include <string>
    #include <time.h>
    #include <stdlib.h>
    #include <getopt.h>
    #include <sys/cygwin.h>
    #include <windows.h>
    #include <imagehlp.h>

    using namespace std;

    string PosixToWin32(const string& aPosixPath);
    void PArgs(int argc, char* argv[]);
    unsigned long StringToUlong(const string& aString);
    void Usage();

    ULONG theImageBase = 0;
    BOOL theDownFlag = FALSE;
    ULONG theOffset = 0;
    int theArgsIndex = 0;

    void
    main(int argc, char* argv[])
    {
    PArgs(argc, argv);
    ULONG aNewImageBase = theImageBase;

    for (int i = theArgsIndex; i < argc; i++)
    {
    if (theDownFlag)
    aNewImageBase -= theOffset;

    string aFile = PosixToWin32(argv[i]);
    ULONG anOldImageSize, anOldImageBase, aNewImageSize;
    ULONG aPrevNewImageBase = aNewImageBase;
    BOOL aStatus = ReBaseImage(
    const_cast<char*>(aFile.c_str()), // CurrentImageName
    0, // SymbolPath
    TRUE, // fReBase
    FALSE, // fRebaseSysfileOk
    theDownFlag, // fGoingDown
    0, // CheckImageSize
    &anOldImageSize, // OldImageSize
    &anOldImageBase, // OldImageBase
    &aNewImageSize, // NewImageSize
    &aNewImageBase, // NewImageBase
    time(0)); // TimeStamp

    // ReBaseImage seems to never returns false!
    DWORD aStatus2 = GetLastError();
    if (aStatus2 != 0)
    {
    cerr << "ReBaseImage() failed with last error = " <<
    GetLastError() << endl;
    exit(2);
    }
    cout << aFile << hex << ": new base = " <<
    ((theDownFlag) ? aNewImageBase : aPrevNewImageBase) <<
    ", new size = " << aNewImageSize + theOffset << endl;

    if (!theDownFlag)
    aNewImageBase += theOffset;
    }

    exit(0);
    }

    string
    PosixToWin32(const string& aPosixPath)
    {
    char aWin32Path[MAX_PATH];
    cygwin_conv_to_win32_path(aPosixPath.c_str(), aWin32Path);
    return aWin32Path;
    }

    void
    PArgs(int argc, char* argv[])
    {
    const char* anOptions = "b:do:";
    for (int anOption; (anOption = getopt(argc, argv, anOptions)) != -1;)
    {
    switch (anOption)
    {
    case 'b':
    theImageBase = StringToUlong(optarg);
    break;
    case 'd':
    theDownFlag = TRUE;
    break;
    case 'o':
    theOffset = StringToUlong(optarg);
    break;
    default:
    Usage();
    exit(1);
    break;
    }
    }

    if (theImageBase == 0)
    {
    Usage();
    exit(1);
    }

    theArgsIndex = optind;
    }

    unsigned long
    StringToUlong(const string& aString)
    {
    stringstream ss;
    unsigned long aUlong;
    string::size_type anIndex = aString.find("0x");
    if (anIndex == 0)
    ss << hex << string(aString, 2, aString.size() - 2);
    else
    ss << aString;
    ss >> aUlong;
    return aUlong;
    }

    void
    Usage()
    {
    cerr << "usage: rebase -b BaseAddress [-d] -o Offset ImageFileName ..." <<
    endl;
    }

    =================
     


    Vadim Guest

Similar Threads

  1. Contribute spawning mfcc.tmp files through dreamweaver
    By DAVIDNM in forum Macromedia Contribute Connection Administrtion
    Replies: 0
    Last Post: January 13th, 09:59 PM
  2. duplicte MC spawning and controlling
    By dontwriteme in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 16th, 08:18 PM
  3. stopping mutliple application spawning ? ? ?? ? ? ? ??
    By a-jayh in forum Macromedia Director Basics
    Replies: 2
    Last Post: February 12th, 02:36 AM
  4. spawning a process
    By Kurt M. Dresner in forum Ruby
    Replies: 7
    Last Post: August 18th, 05:15 PM
  5. Ruby, Threads and Processes
    By ts in forum Ruby
    Replies: 2
    Last Post: July 5th, 08:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139