From: "Iñaki Baz Castillo" Date: 2010-01-15T18:31:30+09:00 Subject: Re: How to know the OS architecture (32 or 64 bits)? El Viernes, 15 de Enero de 2010, Seebs escribió: > On 2010-01-14, Iñaki Baz Castillo wrote: > > Hi, is there a reliable way under Ruby to know the OS architecture (32 or > > 64 bits)? > > Probably not. > > Could you explain what you're trying to do? Without knowing why you think > you need to know this, it's hard to give you good advice. I couldn't tell > you off the top of my head whether the machine I'm working on right now is > 32-bit or 64-bit. I've been doing software development on it for two years > and I've never needed to know. The application I'm developing uses Posix Queue Messages thanks to posix_mq gem: http://bogomips.org/ruby_posix_mq/README.html When the app runs it tries to create a posix mqueue with maxmsg=5000 and msgsize=1024. The user running the application could have not permissions to create such posix mqueue due to system limits ("ulimit -q"). In that case the creation of the posix mqueue raises a Errno::ENOMEM and I want to tell the user the exact amount of bytes required. The algorimth to know such amount of required bytes is: queue.attr.mq_maxmsg * sizeof(struct msg_msg *) + queue.attr.mq_maxmsg * queue.attr.mq_msgsize In 32 bits sizeof(struct msg_msg *) is 4 bytes while in 64 it's 8 bytes, so the total ammount of bytes changes. This means that "ulimit -q" must be different depending on the system architecture (32/64 bits). -- Iñaki Baz Castillo