>> mailbox *new=malloc(sizeof(mailbox));
I wouldn't call any of your variables "new." While allowed in C it isn't very descriptive of what "new" is for. new is also the name of an allocator in C++. I think it's a common enough keyword for you to avoid naming things after it.
>> if(sem_init(new->mailavailable,0,0));
Well it could depend on what sem_int() does, but take note of your semi-colons.
What you have is the equivalent of
Code:
if ( sem_int(new->mailavailable, 0, 0) )
/** do nothing **/ ;
{
/** bad stuff **/
/** improper accessing of "new" because things are executed always **/
}
By the way, no one will be able to tell you where things went wrong if you don't post the other function.