When I execute the first 4 lines of code , it works fine. But the output gives a segmentation fault on executing the sem_getvalue() function. I looke up everywhere for the syntax and other mistakes but I am not being able to find out whats wrong with the code. Can anyone please help me on that...??
I realised that you had asked for the return value of sem_open().Please read my next post after that in which I have mentioned that I got the return value as zero. I also got the return value as zero on using your snippet to print the value.
Since it is returning a zero, I think sem_open() seems to be working fine. But then after that 'segmentation fault' occurs. Notice that this fault doesn't occur if I comment out the sem_getvalue() line from the code.
sem_open() should ideally return the address of the semaphore whereas in this case it is returning 0 ..What can be the probable reasons for the open() call not working?