From owner-freebsd-hackers Tue Nov 21 6: 5:13 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from exchange.universe.dart.spb (mail.dart.sp.ru [195.131.27.95]) by hub.freebsd.org (Postfix) with ESMTP id 6E82637B4C5 for ; Tue, 21 Nov 2000 06:05:08 -0800 (PST) Received: from runnet-gw.marketsite.ru (WILD [192.168.1.24]) by exchange.universe.dart.spb with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id XDG3PHN6; Tue, 21 Nov 2000 17:04:58 +0300 Content-Length: 1827 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200011211357.PAA63147@star.rila.bg> Date: Tue, 21 Nov 2000 17:06:05 +0300 (MSK) Reply-To: diwil@dataart.com From: Dmitry Dicky To: Vladimir Terziev Subject: RE: Semaphore blocking and signal handling Cc: hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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