windows/mac help wanted

Discussion in 'Ruby' started by Ara.T.Howard, Aug 17, 2004.

  1. Ara.T.Howard

    Ara.T.Howard Guest

    rubyists-

    i'd really like to see an interface to posix locking available in ruby for all
    (most) platforms ruby runs on.

    i have an extension for this that should compile fine on any *nix system
    (testers wanted) avialable at

    http://raa.ruby-lang.org/project/posixlock/

    if anyone would like to volunteer to help compile/port this extenstion to
    windows/mac - i would __greatly__ appreciate it. it is a very simple
    extension containing only two methods, so it shouldn't be painful. i would be
    happy to do this myself but do not have access to either windows or mac nodes.

    kind regards.

    -a
    --
    ===============================================================================
    | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    | PHONE :: 303.497.6469
    | A flower falls, even though we love it;
    | and a weed grows, even though we do not love it.
    | --Dogen
    ===============================================================================
     
    Ara.T.Howard, Aug 17, 2004
    #1
    1. Advertising

  2. Compiles fine on my mac:

    vivi ~/src/posixlock-0.0.1 % ruby extconf.rb
    creating Makefile
    vivi ~/src/posixlock-0.0.1 % make
    gcc -fno-common -g -Os -pipe -no-cpp-precomp -fno-common
    -DHAVE_INTTYPES_H -pipe -pipe -I.
    -I/usr/lib/ruby/1.6/powerpc-darwin7.0 -I. -c -o posixlock.o posixlock.c
    cc -fno-common -g -Os -pipe -no-cpp-precomp -fno-common
    -DHAVE_INTTYPES_H -pipe -pipe -dynamic -bundle -undefined suppress
    -flat_namespace -L/usr/lib/ruby/1.6/powerpc-darwin7.0 -L/usr/lib -o
    posixlock.bundle posixlock.o -ldl -lobjc
    vivi ~/src/posixlock-0.0.1 % sudo make install
    posixlock.bundle -> /usr/lib/ruby/1.6/powerpc-darwin7.0/posixlock.bundle
    chmod 0755 /usr/lib/ruby/1.6/powerpc-darwin7.0/posixlock.bundle
    vivi ~/src/posixlock-0.0.1 %

    How should I test it?

    --
    Rando Christensen
    <>
     
    Rando Christensen, Aug 18, 2004
    #2
    1. Advertising

  3. Ara.T.Howard

    Ara.T.Howard Guest

    On Wed, 18 Aug 2004, Rando Christensen wrote:

    > Compiles fine on my mac:


    thanks!


    > vivi ~/src/posixlock-0.0.1 % ruby extconf.rb
    > creating Makefile
    > vivi ~/src/posixlock-0.0.1 % make
    > gcc -fno-common -g -Os -pipe -no-cpp-precomp -fno-common
    > -DHAVE_INTTYPES_H -pipe -pipe -I.
    > -I/usr/lib/ruby/1.6/powerpc-darwin7.0 -I. -c -o posixlock.o posixlock.c
    > cc -fno-common -g -Os -pipe -no-cpp-precomp -fno-common
    > -DHAVE_INTTYPES_H -pipe -pipe -dynamic -bundle -undefined suppress
    > -flat_namespace -L/usr/lib/ruby/1.6/powerpc-darwin7.0 -L/usr/lib -o
    > posixlock.bundle posixlock.o -ldl -lobjc
    > vivi ~/src/posixlock-0.0.1 % sudo make install
    > posixlock.bundle -> /usr/lib/ruby/1.6/powerpc-darwin7.0/posixlock.bundle
    > chmod 0755 /usr/lib/ruby/1.6/powerpc-darwin7.0/posixlock.bundle
    > vivi ~/src/posixlock-0.0.1 %


    > How should I test it?


    require 'posixlock'
    def lock_test
    pid = Process.pid
    42.times do
    open(__FILE__,'r+'){|f| f.posixlock(File::LOCK_EX) and puts "locked by <#{ pid }>"}
    end
    end
    fork ? lock_test && Process.wait : lock_test


    it is nice to run this on an nfs mounted file system - but not required...

    -a
    --
    ===============================================================================
    | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    | PHONE :: 303.497.6469
    | A flower falls, even though we love it;
    | and a weed grows, even though we do not love it.
    | --Dogen
    ===============================================================================
     
    Ara.T.Howard, Aug 18, 2004
    #3
  4. Ara.T.Howard wrote:
    > require 'posixlock'
    > def lock_test
    > pid = Process.pid
    > 42.times do
    > open(__FILE__,'r+'){|f| f.posixlock(File::LOCK_EX) and puts
    > "locked by <#{ pid }>"}
    > end
    > end
    > fork ? lock_test && Process.wait : lock_test


    I don't have nfs to test on currently, but I assume this means it worked? :

    vivi ~/src/posixlock-0.0.1 % ruby test.rb
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1277>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1276>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>
    locked by <1277>


    --
    Rando Christensen
    <>
     
    Rando Christensen, Aug 18, 2004
    #4
  5. Ara.T.Howard

    Ara.T.Howard Guest

    On Wed, 18 Aug 2004, Rando Christensen wrote:

    > Ara.T.Howard wrote:
    >> require 'posixlock'
    >> def lock_test
    >> pid = Process.pid
    >> 42.times do
    >> open(__FILE__,'r+'){|f| f.posixlock(File::LOCK_EX) and puts
    >> "locked by <#{ pid }>"}
    >> end
    >> end
    >> fork ? lock_test && Process.wait : lock_test

    >
    > I don't have nfs to test on currently, but I assume this means it worked? :
    >
    > vivi ~/src/posixlock-0.0.1 % ruby test.rb
    > locked by <1276>
    > locked by <1276>


    yup.

    thanks a bunch. mac __are__ nice i guess! now all i have to do is deal with
    the windows thing...

    regards.

    -a
    --
    ===============================================================================
    | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    | PHONE :: 303.497.6469
    | A flower falls, even though we love it;
    | and a weed grows, even though we do not love it.
    | --Dogen
    ===============================================================================
     
    Ara.T.Howard, Aug 18, 2004
    #5
  6. Ara.T.Howard

    Dan Janowski Guest

    Windows seems to exclusive lock when a file is opened for writing by
    default. I have been unable to find a way around it. There cannot be a
    reader, and then another process open the file for writing.

    I may have missed something, but maybe you need to only hold open a
    file for writing.

    If this is not the case, or there is a way around it, I am interested
    to know.

    Dan


    On Aug 17, 2004, at 22:50, Ara.T.Howard wrote:

    > On Wed, 18 Aug 2004, Rando Christensen wrote:
    >
    >> Ara.T.Howard wrote:
    >>> require 'posixlock'
    >>> def lock_test
    >>> pid = Process.pid
    >>> 42.times do
    >>> open(__FILE__,'r+'){|f| f.posixlock(File::LOCK_EX) and puts
    >>> "locked by <#{ pid }>"}
    >>> end
    >>> end
    >>> fork ? lock_test && Process.wait : lock_test

    >>
    >> I don't have nfs to test on currently, but I assume this means it
    >> worked? :
    >>
    >> vivi ~/src/posixlock-0.0.1 % ruby test.rb
    >> locked by <1276>
    >> locked by <1276>

    >
    > yup.
    >
    > thanks a bunch. mac __are__ nice i guess! now all i have to do is
    > deal with
    > the windows thing...
    >
    > regards.
    >
    > -a
    > --
    > =======================================================================
    > ========
    > | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    > | PHONE :: 303.497.6469
    > | A flower falls, even though we love it;
    > | and a weed grows, even though we do not love it. | --Dogen
    > =======================================================================
    > ========
    >
     
    Dan Janowski, Aug 18, 2004
    #6
  7. Ara.T.Howard

    Ara.T.Howard Guest

    On Wed, 18 Aug 2004, Dan Janowski wrote:

    > Windows seems to exclusive lock when a file is opened for writing by
    > default. I have been unable to find a way around it. There cannot be a
    > reader, and then another process open the file for writing.
    >
    > I may have missed something, but maybe you need to only hold open a
    > file for writing.
    >
    > If this is not the case, or there is a way around it, I am interested
    > to know.


    i know nothing of windows but, in my case, i'm using posixlock to lock an
    empty nfs mounted semaphore file. i'm guessin the windows nfs client is that
    quite smart enough to know that some process on another machine is holding a
    lock...

    also LockFile exists for windows according to some of the source i've looked
    at...

    but, like i said, i know _nothing_ of windows. please enlighten if you have
    further comments!

    cheers.

    -a

    >
    > Dan
    >
    >
    > On Aug 17, 2004, at 22:50, Ara.T.Howard wrote:
    >
    >> On Wed, 18 Aug 2004, Rando Christensen wrote:
    >>
    >>> Ara.T.Howard wrote:
    >>>> require 'posixlock'
    >>>> def lock_test
    >>>> pid = Process.pid
    >>>> 42.times do
    >>>> open(__FILE__,'r+'){|f| f.posixlock(File::LOCK_EX) and puts
    >>>> "locked by <#{ pid }>"}
    >>>> end
    >>>> end
    >>>> fork ? lock_test && Process.wait : lock_test
    >>>
    >>> I don't have nfs to test on currently, but I assume this means it
    >>> worked? :
    >>>
    >>> vivi ~/src/posixlock-0.0.1 % ruby test.rb
    >>> locked by <1276>
    >>> locked by <1276>

    >>
    >> yup.
    >>
    >> thanks a bunch. mac __are__ nice i guess! now all i have to do is
    >> deal with
    >> the windows thing...
    >>
    >> regards.
    >>
    >> -a
    >> --
    >> =======================================================================
    >> ========
    >> | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    >> | PHONE :: 303.497.6469
    >> | A flower falls, even though we love it;
    >> | and a weed grows, even though we do not love it. | --Dogen
    >> =======================================================================
    >> ========
    >>

    >
    >
    >
    >


    -a
    --
    ===============================================================================
    | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
    | PHONE :: 303.497.6469
    | A flower falls, even though we love it;
    | and a weed grows, even though we do not love it.
    | --Dogen
    ===============================================================================
     
    Ara.T.Howard, Aug 18, 2004
    #7
  8. Ara.T.Howard wrote:
    > yup.
    >
    > thanks a bunch. mac __are__ nice i guess!


    As I understand it, most of the problems (I'd estimate somewhere around
    80%, but I have nothing to back that number up) involved in porting unix
    software to osx (not taking the gui into account at all, of course) are
    the differences in how libraries work and small tweaks to the compiler
    to account for it, and a surprising number of things really do work
    exactly how they'd work in a freebsd system.

    Which is very nice indeed. :)

    --
    Rando Christensen
    <>
     
    Rando Christensen, Aug 18, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harvey
    Replies:
    0
    Views:
    794
    Harvey
    Jul 16, 2004
  2. Harvey
    Replies:
    1
    Views:
    902
    Daniel
    Jul 16, 2004
  3. Mark Hahn
    Replies:
    7
    Views:
    323
    Mark Hahn
    Sep 18, 2003
  4. Apple Grew

    Help wanted in piping in Windows

    Apple Grew, Jun 23, 2005, in forum: Python
    Replies:
    2
    Views:
    341
    Peter Hansen
    Jun 24, 2005
  5. Ian Kelly
    Replies:
    3
    Views:
    395
    Arnaud Delobelle
    Feb 16, 2012
Loading...

Share This Page