A
Ara.T.Howard
i have a bit of code that packs an flock struct
struct flock {
...
short l_type; /* Type of lock: F_RDLCK,
F_WRLCK, F_UNLCK */
short l_whence; /* How to interpret l_start:
SEEK_SET, SEEK_CUR, SEEK_END */
off_t l_start; /* Starting offset for lock */
off_t l_len; /* Number of bytes to lock */
pid_t l_pid; /* PID of process blocking our lock
(F_GETLK only) */
...
};
using 'ssqqi' (thanks to matz for this tip). this works for linux, but i'm
sure it won't for other *nixes with different flock layouts. if i understand
ruby dl there is no way to portably set the fields of a struct unless you
already know it's layout, so packing is just as good in this case (please
correct me if i'm wrong). what i'm asking for people on various *nixes to
post their struct flock definitions so i can add appropriate pack templates
for those.
this output of
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
would also be useful
if there is an easier way to do this - some online resource where i could find
this info - please let me know
thanks alot.
-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
===============================================================================
struct flock {
...
short l_type; /* Type of lock: F_RDLCK,
F_WRLCK, F_UNLCK */
short l_whence; /* How to interpret l_start:
SEEK_SET, SEEK_CUR, SEEK_END */
off_t l_start; /* Starting offset for lock */
off_t l_len; /* Number of bytes to lock */
pid_t l_pid; /* PID of process blocking our lock
(F_GETLK only) */
...
};
using 'ssqqi' (thanks to matz for this tip). this works for linux, but i'm
sure it won't for other *nixes with different flock layouts. if i understand
ruby dl there is no way to portably set the fields of a struct unless you
already know it's layout, so packing is just as good in this case (please
correct me if i'm wrong). what i'm asking for people on various *nixes to
post their struct flock definitions so i can add appropriate pack templates
for those.
this output of
ruby -r rbconfig -e 'p Config::CONFIG["arch"]'
would also be useful
if there is an easier way to do this - some online resource where i could find
this info - please let me know
thanks alot.
-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
===============================================================================