Date: Tue, 21 Nov 2000 17:06:05 +0300 (MSK) From: Dmitry Dicky <diwil@dataart.com> To: Vladimir Terziev <vladimirt@rila.bg> Cc: hackers@FreeBSD.ORG Subject: RE: Semaphore blocking and signal handling Message-ID: <XFMail.001121170605.diwil@dataart.com> In-Reply-To: <200011211357.PAA63147@star.rila.bg>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, easy: ------------------------------- extern int errno; int sem_lock(int semnumb) { struct sembuf sb[2]; sb[0].sem_num = semnumb; sb[0].sem_op = -1; sb[0].sem_flg = 0; again: if( semop(sh->sem, sb,1) ) { errmsg("Semaphore %d erorr: %s\n",sh->sem, strerror(errno)); // here you'll see the reason why semaphore returned an error if(errno = EINTR) goto again; return -1; } return 0; } ---------------------------------- At least it works in my case. Regards, D. On 21-Nov-00 Vladimir Terziev wrote: > Hi. > > Am I right for the following: > > When a process is blocked on semop (trying to get resource) and receives > a signal (for which the process has a handler), the process gets > unblocked > from the semop wait (to handle the signal), and after handling the > signal > continues with the instruction after semop, as if it was unblocked by > successful semop. > > Is this behaviour normal, and is there a way for the process to > distinguish > between signal handling unblock and successful semop operation (may be > by > setting a global variable in the signal-handling function) ? > > Thank you in advance. > > Vladimir Terziev > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message -- ********************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) DataArt Enterprises, Inc. (_Y_.)' ._ ) `._ `. ``-..-' Serpukhovskaja street, 10 _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 3261780, 5585314 ********************************************************************** To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.001121170605.diwil>