[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

race in malloc(3)?



Is it ok that the following program fails?

#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
        switch (rfork(RFPROC | RFMEM)) {
        case -1:
                perror("rfork()");
                exit(-1);
        case 0:
                malloc(1);
                exit(0);
        }

        usleep(1);
        malloc(1);
        /* Core dumped here */
}

-- 
   Alexander Yurchenko (aka grange)