I just run a example program from the book unp2v2
written W.Richard Stevens. The program includes a call
to sem_open. The compilation was ok. But when I run it
on FreeBSD 5-current(recent),the system print "Bad
system call (core dumped)". The program code :

#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>

#define FILE_MODE       (S_IRUSR | S_IWUSR | S_IRGRP |
S_IROTH)

int
main(int argc, char **argv)
{
        int             c, flags;
        sem_t   *sem;
        unsigned int    value;

        flags = O_RDWR | O_CREAT;
        value = 1;
        while ( (c = getopt(argc, argv, "ei:")) != -1) {
                switch (c) {
                case 'e':
                        flags |= O_EXCL;
                        break;

                case 'i':
                        value = atoi(optarg);
                        break;
                }
        }
        if (optind != argc - 1)
        {
                printf("usage: semcreate [ -e ] [ -i initalvalue ]
<name>");
                exit(1);
        }

        if((sem = sem_open(argv[optind], flags, FILE_MODE,
value))==SEM_FAILED)
        {
                perror("semaphore creation failed");
                exit(1);
        }
        sem_close(sem);
        exit(0);
}


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to