shmget() and shmat() problem

Discussion in 'Mac Programming' started by acidity, May 29, 2007.

  1. acidity macrumors regular

    Joined:
    Sep 7, 2006
    #1
    Hello

    I am trying to compile http://www.dbmail.org/ on my MacBook. I have successfuly compiled it on FreeBSD and Ubuntu so it should work on Mac OS X too.

    One of the file has the following code:

    Code:
    void scoreboard_new(serverConfig_t * conf)
    {
        int serr;
        if ((shmid = shmget(IPC_PRIVATE,
                (sizeof(child_state_t) * HARD_MAX_CHILDREN),
                0644 | IPC_CREAT)) == -1) {
            serr = errno;
            TRACE(TRACE_FATAL, "shmget failed [%s]",
                    strerror(serr));
        }   
        scoreboard = shmat(shmid, (void *) 0, 0); 
        serr=errno;
        if (scoreboard == (Scoreboard_t *) (-1)) {
            TRACE(TRACE_FATAL, "scoreboard init failed [%s]",
                  strerror(serr));
            scoreboard_delete();
        }   
        scoreboard_lock_new();
        scoreboard->conf = conf;
        scoreboard_setup();
        scoreboard_conf_check();
    
        /* Make sure that we clean up our shared memory segments when we exit
         * normally (i.e. not by kill -9, if you do that, you get to clean this
         * up yourself!)
         * */
        atexit(scoreboard_delete); }
    
    The code compiles correctly but shmget() and shmat() fails with error:

    shmget failed [No space left on device]
    scoreboard init failed [Permission denied]

    I tried to follow the steps given at http://www.spy-hill.net/help/apple/SharedMemory.html to solve the shmget() issue but without success. For the second issue, I found:

    http://developer.apple.com/technotes/tn2002/tn2053.html

    A problem where shmat would fail with a permission denied error when it was attempted by root has been corrected. (r. 2910913).

    but apparently it still fails on my Mac OS X Tiger.

    Any ideas?
     
  2. acidity thread starter macrumors regular

    Joined:
    Sep 7, 2006

Share This Page