Re: Problems with socket created before fork() in multi-threaded application
Philip Guenther wrote: > On Thu, Mar 20, 2008 at 3:01 PM, Tvrvk Edwin <[EMAIL PROTECTED]> wrote: > >> ClamAV has changed to call fork() after creating its local socket. >> This causes weird behaviours when communicating on the socket [1] >> >> If fork() is called before creating the socket() it works. >> >> Is it safe to create a socket, fork(), and then call pthread_create() >> and read from the socket? >> > > The relevant passages from the Single Unix Specification were cited in > the thread on the FreeBSD list. The rule is that if the process had > more than one thread when fork() was called, then the child can only > call async-signal safe functions until it calls execle(), execve(), > _exit(), or _Exit(). pthread_create() is not async-signal safe, so to > answer your question to you have to look at the state of the process > before the call to fork(). > > The underlying problem is that after the fork(), the child's state may > include such things as mutexes which are locked by threads that no > longer exist and mutexes that have non-existent threads in their > 'waiting' queue. pthread_create() probably needs to allocate memory > for the thread's handle and stack; if some other thread was in > malloc() at the time of the fork(), then the heap is probably both > locked and inconsistent in the child. > Thanks for the detailed explanation, however threads are created only after fork(). fork() is used to daemonize the process. > > >> It seems not to work, the thread gets stuck in pthread_mutex_lock(), and >> it is not woken up even after the mutex is free. Moving fork() before >> the socket avoids this. >> Is this intended behaviour or a bug? >> > > If there was more than one thread in the process when fork() was > called, then it's a bug in clamav. Period. > > (If there were any threads before the fork() that may have been > blocked on the mutex, then the behavior is completely predictable, as > the mutex's wait queue has an entry for a thread that no longer > exists.) > > No threads are created before calling fork(), it only parses its configuration files, loads the database, and creates the socket. pthread_create is called after the fork(), in the child. pthread_create is called while a mutex is locked, could that be a problem? It calls pthread_mutex_lock()/unlock() before fork(), but even if I temporarely comment out those, I am still seeing the weird behavior. Thanks, --Edwin
Failing Disk?
I keep having an odd problem. The system will lockup completely, be unreachable from other hosts on my LAN, and require a power cycle to get going again... Ya, I know, not a nice thing to do to your disks. Anyhow, I regularly fail the normal boot fsck on my /usr partition and need to run it manually. The manual fsck finds and deletes some of the old working directories ("w-") in my ports tree. The system is using an LSI MegaRAID SATA 150-6 with six 160GB drives. They are configure into a single mirrored+striped logical volume. Yes, I've got backups via dump(8) saved to a PATA disk (wd0), so I'm not too worried about the data. The wd0 disk is in a removable carrier and is normally not installed. Yes, there are multiple backups on multiple PATA disks. On the main logical disk (sd0) partition sizes were kept sane (100GB) considering the amount of RAM I have (1GB). # df -h Filesystem SizeUsed Avail Capacity Mounted on /dev/sd0a 1006M 53.6M902M 6%/ /dev/sd0i 98.4G 21.3G 72.2G23%/arc /dev/sd0h 98.4G 10.7G 82.8G11%/home /dev/sd0d 3.9G 18.0K3.7G 0%/tmp /dev/sd0g 39.4G 18.5G 18.9G49%/usr /dev/sd0e 3.9G 74.2M3.7G 2%/var /dev/wd0a 230G 94.6G124G43%/mnt My *guess* is one of the raid disks is slowly failing but I'm not seeing any errors in /var/log/messages What's a good way to go about trouble shooting this situation and hopefully isolating which disk is failing (assuming my guess is correct). dmesg below Thanks, JCR dmesg.boot OpenBSD 4.2-stable (GENERIC.MP) #0: Fri Feb 29 10:58:12 PST 2008 [EMAIL PROTECTED]:/usr/src/sys/arch/i386/compile/GENERIC.MP cpu0: Intel(R) Xeon(TM) CPU 2.00GHz ("GenuineIntel" 686-class) 2 GHz cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM real mem = 1072754688 (1023MB) avail mem = 1029603328 (981MB) mainbus0 at root bios0 at mainbus0: AT/286+ BIOS, date 11/01/04, BIOS32 rev. 0 @ 0xffe90, SMBIOS rev. 2.3 @ 0xf0450 (114 entries) bios0: vendor Dell Computer Corporation version "A11" date 11/01/2004 bios0: Dell Computer Corporation Precision WorkStation 530 MT apm0 at bios0: Power Management spec V1.2 apm0: AC on, battery charge unknown apm0: flags 30102 dobusy 0 doidle 1 pcibios0 at bios0: rev 2.1 @ 0xf/0x1 pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfba00/224 (12 entries) pcibios0: PCI Interrupt Router at 000:31:0 ("Intel 82801BA LPC" rev 0x00) pcibios0: PCI bus #4 is the last bus bios0: ROM list: 0xc/0x8800 0xc8800/0x2800 0xcb000/0x1800 mainbus0: Intel MP Specification (Version 1.4) cpu0 at mainbus0: apid 0 (boot processor) cpu0: apic clock running at 99 MHz cpu1 at mainbus0: apid 1 (application processor) cpu1: Intel(R) Xeon(TM) CPU 2.00GHz ("GenuineIntel" 686-class) 2 GHz cpu1: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM mainbus0: bus 0 is type PCI mainbus0: bus 1 is type PCI mainbus0: bus 2 is type PCI mainbus0: bus 3 is type PCI mainbus0: bus 4 is type PCI mainbus0: bus 5 is type ISA ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins ioapic0: misconfigured as apic 0, remapped to apid 2 pci0 at mainbus0 bus 0: configuration mode 1 (no bios) pchb0 at pci0 dev 0 function 0 "Intel 82860 Host" rev 0x04: rng active, 800Kb/sec ppb0 at pci0 dev 1 function 0 "Intel 82850/82860 AGP" rev 0x04 pci1 at ppb0 bus 1 vga1 at pci1 dev 0 function 0 "Matrox MGA G400/G450 AGP" rev 0x82 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) ppb1 at pci0 dev 2 function 0 "Intel 82860 PCI-PCI" rev 0x04 pci2 at ppb1 bus 2 ppb2 at pci2 dev 31 function 0 "Intel 82806AA" rev 0x03 pci3 at ppb2 bus 3 "Intel 82806AA APIC" rev 0x01 at pci3 dev 0 function 0 not configured ami0 at pci3 dev 13 function 0 "Symbios Logic MegaRAID" rev 0x01: apic 2 int 21 (irq 11) ami0: LSI 523, 32b, FW 713R, BIOS vG121, 64MB RAM ami0: 1 channels, 0 FC loops, 1 logical drives scsibus0 at ami0: 40 targets sd0 at scsibus0 targ 0 lun 0: SCSI2 0/direct fixed sd0: 457749MB, 58354 cyl, 255 head, 63 sec, 512 bytes/sec, 937469952 sec total scsibus1 at ami0: 16 targets ppb3 at pci0 dev 30 function 0 "Intel 82801BA AGP" rev 0x04 pci4 at ppb3 bus 4 xl0 at pci4 dev 11 function 0 "3Com 3c905C 100Base-TX" rev 0x78: apic 2 int 23 (irq 10), address 00:06:5b:87:ad:bd exphy0 at xl0 phy 24: 3Com internal media interface "TI TSB12LV26 FireWire" rev 0x00 at pci4 dev 12 function 0 not configured em0 at pci4 dev 14 function 0 "Intel PRO/1000T (82544GC)" rev 0x02: apic 2 int 18 (irq 11), address 00:02:b3:96:13:11 ichpcib0 at pci0 dev 31 function 0 "Intel 82801BA LPC" rev 0x04: 24-bit timer at 3579545Hz pciide0 at pci0 dev 31 function 1 "Intel 82801BA IDE" rev 0x04: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility wd0 at pciide
Re: [OT] Pursuing Management to adopt OpenBSD
Chris wrote: > ... > Is there any way I could convince these people to make the move to > OpenBSD? Suggestions, tips and tricks along with real life examples > would be much appreciated. Thanks. Be seen using it ...and let them think they figured out on their own that you are. If you have to bring attention, do it on the side. e.g. at the end of a presentation (where the content was received positively) mention the name of the OS, DE and application in as few words as possible and then steer immediately back to the topic of the post-presentation discussion. Let people use it. Show them how to make customizations. Set up workstations or desktops that people can try. There should be someone willing to help you draft a proof of concept prototype. As you point out, familiarity (or the perception of familiarity) is a problem. And if they don't use it, they can't become familiar. Familiarity is one of the non-technical factors you must keep in mind. The damage from marketing is another. OpenBSD has several competing or complimentary systems and one opponent. But also realize that, despite what that one opponent calls itself or what ever it may file with the SEC, you are going up against an interest which operates as if it were a rather nasty political or religious movement. The word they use in-house for their action is 'jihad' see the PDF linked to from the Groklaw post. http://www.groklaw.net/article.php?story=20071023002351958 (Note: that the above site is blocked in a number of countries and you may need a proxy to get at it.) Regards, -Lars
Re: Problems with socket created before fork() in multi-threaded application
On Fri, Mar 21, 2008 at 1:44 AM, Tvrvk Edwin <[EMAIL PROTECTED]> wrote: > Philip Guenther wrote: > > On Thu, Mar 20, 2008 at 3:01 PM, Tvrvk Edwin <[EMAIL PROTECTED]> wrote: > >> ClamAV has changed to call fork() after creating its local socket. > >> This causes weird behaviours when communicating on the socket [1] > >> > >> If fork() is called before creating the socket() it works. > >> > >> Is it safe to create a socket, fork(), and then call pthread_create() > >> and read from the socket? ... > fork() is used to daemonize the process. Okay, it's a bug in libpthread. The user-space thread implementation of libpthread sets all the file descriptors to be non-blocking (O_NONBLOCK) so that it can catch blocking I/O and perform a context switch to another thread when that happens. This is hidden from the application itself: if a threaded app calls fcntl(fd, F_GETFL), the library will hide the O_NONBLOCK flag unless the app actually called fcntl() to set it. When a process exits, the library resets the fds back to blocking if they were only non-blocking for the library; this is so that other, non-threaded apps don't get confused when /dev/tty is left non-blocking, and things like that. That last bit is the catch: when the parent exits after calling fork, the socket is reset to blocking and the child never sets it back to non-blocking again. It's not clear to me how the child can reliably detect that this has occurred. It could use a kqueue/kevent to detect when its parent has exited, but the reset could just as well be done by the child's grandparent (consider a double-fork daemonize). As a gross kludge, I think things would "work" if you added the following to the code called by the child after the fork. sleep(1); /* make sure the parent has a chance to exit */ fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) & ~O_NONBLOCK); (With the correct 'sockfd' variable, of course). That'll bring the kernel's O_NONBLOCK flag on the socket in sync with what libpthread thinks it should be. I'll note that I see a *bunch* of other fork() calls in the clamav source (0.92.1), some of which look very dubious in terms of safety. For example, dirscan() in clamd/scanner.c has a threadpool_t argument, so I presume it's called after threads have been spawned, yet it calls virusaction() which calls fork() and the child calls strdup(), malloc(), putenv(), system(), and exit(), none of which are async-signal safe. Philip Guenther
Re: Failing Disk?
On 2008-03-21, J.C. Roberts <[EMAIL PROTECTED]> wrote: > What's a good way to go about trouble shooting this situation and > hopefully isolating which disk is failing (assuming my guess is > correct). dmesg below I assume you have already checked bioctl and information in the ctrl-m utility for anything unusual? Here's one method: move the disks one by one to another machine with a normal SATA controller, either boot an OS from another driver (don't mount them) and check SMART status (probably useless, but you never know...) and try reading the whole disk with dd and look for errors/timeouts, or alternatively run the drive manufacturer's testing tool - you can usually find these by looking for the RMA procedure on their website. Should be safe, but I would not want to do this without the backups, just in case. :-)
Undelivered mail
--> Error description: Error-For: [EMAIL PROTECTED] Error-Code: 5.1.1 Error-Text: No such list. Error-End: One error reported. Reporting-MTA: dns; LISTS.UFL.EDU Final-Recipient: RFC822; [EMAIL PROTECTED] Action: failed Status: 5.1.1 (No such list)
Re: another spamd log question
Hi, I forgot to say that I am runnning OpenBSD 4.2 and spamd in greylisting mode and all default parameters (-G). My understanding is that if an IP address, after 4 hours of the initial greylist entry, has not been whitelisted yet, then it was a spammer who gave up because of the greylisting process. But I am not quite sure if there other (signifcant) situations which may occur in a similar way that I should not account for. Thanks for any comments. Regards, Jose. -- Want an e-mail address like mine? Get a free e-mail account today at www.mail.com!
Re: [OT] Pursuing Management to adopt OpenBSD
Chris schreef: I been trying (rather unsuccessfully) to convince various clients and employers to adopt OpenBSD. Most people, I find, are resistent to change and would not use anything they are not familiar with. Others would say that if I leave the job, it would be hard to find people who can use (or even heard of) OpenBSD and in some places Management never heard of OpenBSD and have very little clue as to how good or bad it is compared to Linux/ Solaris and Windows thus they will just knock off the proposal in 2 seconds. Is there any way I could convince these people to make the move to OpenBSD? Suggestions, tips and tricks along with real life examples would be much appreciated. Thanks. Many others have given great pro-OpenBSD examples. I can only give you the "tricks" I have succesfully used in the passed. These are based on selling solutions - not on convincing people how great OpenBSD is. There is a big difference from my perspective, but our goals are the same. Meetings work far better than writing to get your points across. They allow you to change your direction on the fly if needed, while writing just gets /dev/nulled TRICK 1: Expensive beats free First of all - forget it is free. Forget the whole licencing, forget anything open source software related. That sounds weird and perhaps unethical towards those that fight for this but it helps getting what you want. OpenBSD will eventually benefit - so we're in the clear here. Management does not trust anything free. Free implicates 'no guarantees'. Whenever you say 'free' management pictures a photograph of you and Richard Stallman, holding hands under a rainbow while a unicorn flies by. If, and only if, the price question pops up you say 'implementation will probably cost us around give OpenBSD a nice donation>' (If the guy is wearing a suit worth more than your monthly salary multiply the amount by 10.) TRICK 2: Fear beats comfortable with what we have Talk about the changing internet/network. How it is increasingly becoming more and more hostile. They will be aware of this. through both the press and those Nigerian relatives that keep mailing them. Tell them about the recent creditcard thefts, about the impact these things have on a company. This can be on a moderate level or on a 'oh my god the plane is crashing and we are all going to die!' level. Depends on your party and your ethics. Mention the amount of attacks on a webserver can go down by 40% just because the bad guys see it is running OpenBSD, or that common cracking techniques that work on other systems simply are impossible on OpenBSD because of it's design. Show nice little graphs of security exploits on all the systems they know and place OpenBSDs track record next to it. Do this only for basic issues and you'll have pretty dramatic stats. If you can (without loosing your job or crossing your co-workers) present a list of unpatched / unsolved issues with the current servers. Don't talk tech. Talk solutions. We have a problem here and I am offering you the solution. World leaders have gotten (and are getting) away with incredible stuff, solely by addressing people's fear. It is by far the most powerful emotion. And before you judge me on this - you do have insurance, don't you? Exactly. TRICK 3: Trustworthy beats unknown Tell them who else is using it; which big companies (they know) already have put their trust in it. Knowing some company they respect is using OpenBSD proves to them it's a reliable choice. These companies have understood the need for solutions for the problems presented earlier in trick 2. Choose companies that deal with important stuff. Hospitals and banks are great examples. Yes, it might just be a single router among the ninety Windows boxes but who cares? If they mention seeing Windows in their hospital tell them this is why you and your family never go to that hospital. TRICK 4: Being cool beats missing the boat Present OpenBSD as 'up and coming', give them the idea they are jumping in right on time. That it is a fresh, new and hip approach to operating systems. OpenBSD is lean, mean - it's sexy. "Actually, you are a pretty lame bunch considering you're not running it yet." That approach, no matter how stupid, might work better in some cases than actual arguments. Especially if most of the people in the room are carrying an iPhone. TRICK 5: Action beats promise Emphasize on the low costs of running OpenBSD. The low maintenance, the fact it performs great without non-cutting-edge hardware. Do not say it runs great on 'old' hardware. Old is bad, old will break. Low system requirements, now that sounds like we can save some cash. Convince them of the low learning curve in maintaining, upgrading and installing systems. Anybody can do it. Propose to teach Janet, the hot secretary from upstairs, to upgrade a system within a day - just to prove your point. This is a proposition I have yet
Re: [OT] Pursuing Management to adopt OpenBSD
> From: Chris > Subject: [OT] Pursuing Management to adopt OpenBSD > > > I been trying (rather unsuccessfully) to convince various clients and > employers to adopt OpenBSD. Most people, I find, are resistent to > change and would not use anything they are not familiar with. Others > would say that if I leave the job, it would be hard to find people who > can use (or even heard of) OpenBSD and in some places Management never > heard of OpenBSD and have very little clue as to how good or bad it is > compared to Linux/ Solaris and Windows thus they will just knock off > the proposal in 2 seconds. > > Is there any way I could convince these people to make the move to > OpenBSD? Suggestions, tips and tricks along with real life examples > would be much appreciated. Thanks. > > I have been in this same boat. The company I work for was a completely Windows environment when I was hired. Any suggestions of anything non- Windows was answered with angry looks and the mantra "We are a Windows shop! We are not interested in anything else!" Then it happened. One of the big Win2003 FTP servers went down... hard... very hard... smoke rolling out of it hard... and everyone was running around crying "Oh noes! Oh noes! What'll we do?" because nobody bothered to come up with a disaster recovery plan beyond "load up another box and put it out there" and as many of us unlucky bastards know, It takes all day to get a Win2003 server ready for deployment, especially if that deployment is one that connects it to the Wild Wooly Internet. Now, normally their plan would have been fine because this particular business (at the time) could live without their FTP server for that amount of time but fate stepped in and they really needed their FTP server to be up and running for a particular reason that evening. So, I calmly walked in and made the boast that I could get them an FTP server up and running in a matter of an hour or two. They were just desperate enough to call me on it. We used that first OpenBSD 3.6 based FTP server for a couple years upgrading as we went. We are now running OpenBSD 4.2 (soon to be upgraded to 4.3 YAY!) oddly enough on the same (repaired) box that used to house the Win2003 FTP server. The bosses have never looked back, and never regretted giving a lowly "data processor" a chance to pull their biscuits out of the fire by building an OpenBSD FTP server. I have FINALLY even talked them into supporting the project by pre-ordering 4.3 (and a nice t-shirt for me). Oh, and that first OpenBSD FTP server has been joined by 8 or 9 other OpenBSD boxes doing various this-and-thats around the place. Firewalls, mail servers, Time server, NIDS, Web Application server, and just about anything else that I can throw together using spare parts while the Windows tards are still trying to calculate the Hardware, OS, and Licensing costs to implement. I still haven't been able to break the SQL server or Domain Controller barrier yet, but give me time. The boss is finally admitting that maybe we could do a few projects with something other than Visual Basic... Change comes slowly sometimes. s
Re: OpenBSD Strage Problem
just to eliminate the obvious: you have checked that packet forwarding is enabled? Yes it is enable. My client is function properly. Let me try to put "up" in the hostname.ral0 file and see if this help. Why my wired connection can ping from both way but cannot browse ? A billion thanks for your help. -- View this message in context: http://www.nabble.com/OpenBSD-Strage-Problem-tp16062121p16198089.html Sent from the openbsd user - misc mailing list archive at Nabble.com.
Re: openbsd game server
I would ask them what games they'd be interested in playing first, then seeing if it's possible to run those games (or their functional equivalents) on OBSD. danno -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of arthur Sent: Thursday, March 20, 2008 4:32 PM To: Openbsd Misc (E-mail) Subject: openbsd game server Hi All, I am thinking about running a game server for my daughter and her friends. Any suggestion for a multi-user (with a gui user end). Thanks. Arthur
Re: Problems with socket created before fork() in multi-threaded application
On Friday 21 March 2008 6:25:59 am Philip Guenther wrote: > On Fri, Mar 21, 2008 at 1:44 AM, Tvrvk Edwin <[EMAIL PROTECTED]> wrote: > > Philip Guenther wrote: > > > On Thu, Mar 20, 2008 at 3:01 PM, Tvrvk Edwin <[EMAIL PROTECTED]> > wrote: > > >> ClamAV has changed to call fork() after creating its local socket. > > >> This causes weird behaviours when communicating on the socket [1] > > >> > > >> If fork() is called before creating the socket() it works. > > >> > > >> Is it safe to create a socket, fork(), and then call pthread_create() > > >> and read from the socket? > ... > > fork() is used to daemonize the process. > > Okay, it's a bug in libpthread. The user-space thread implementation > of libpthread sets all the file descriptors to be non-blocking > (O_NONBLOCK) so that it can catch blocking I/O and perform a context > switch to another thread when that happens. This is hidden from the > application itself: if a threaded app calls fcntl(fd, F_GETFL), the > library will hide the O_NONBLOCK flag unless the app actually called > fcntl() to set it. When a process exits, the library resets the fds > back to blocking if they were only non-blocking for the library; this > is so that other, non-threaded apps don't get confused when /dev/tty > is left non-blocking, and things like that. > > That last bit is the catch: when the parent exits after calling fork, > the socket is reset to blocking and the child never sets it back to > non-blocking again. Your analysis is correct. > It's not clear to me how the child can reliably detect that this has > occurred. It could use a kqueue/kevent to detect when its parent has > exited, but the reset could just as well be done by the child's > grandparent (consider a double-fork daemonize). Indeed this is a nasty limitation of userland threads that doesn't have an easy solution. > As a gross kludge, I think things would "work" if you added the > following to the code called by the child after the fork. >sleep(1); /* make sure the parent has a chance to exit */ >fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) & ~O_NONBLOCK); > > (With the correct 'sockfd' variable, of course). That'll bring the > kernel's O_NONBLOCK flag on the socket in sync with what libpthread > thinks it should be. To avoid the race in the child (and the sleep() call), the parrent can set the fd's to non-blocking *before* the fork() and the child can set them back to blocking directly after the fork. Obviously not ideal but it will work-around the problem effectively. > I'll note that I see a *bunch* of other fork() calls in the clamav > source (0.92.1), some of which look very dubious in terms of safety. > For example, dirscan() in clamd/scanner.c has a threadpool_t argument, > so I presume it's called after threads have been spawned, yet it calls > virusaction() which calls fork() and the child calls strdup(), > malloc(), putenv(), system(), and exit(), none of which are > async-signal safe. > > Yuck -Kurt
Re: Problems with socket created before fork() in multi-threaded application
On Friday 21 March 2008 10:47:27 am Kurt Miller wrote: > On Friday 21 March 2008 6:25:59 am Philip Guenther wrote: > > On Fri, Mar 21, 2008 at 1:44 AM, Tvrvk Edwin <[EMAIL PROTECTED]> wrote: > > > Philip Guenther wrote: > > > > On Thu, Mar 20, 2008 at 3:01 PM, Tvrvk Edwin <[EMAIL PROTECTED]> > > wrote: > > > >> ClamAV has changed to call fork() after creating its local socket. > > > >> This causes weird behaviours when communicating on the socket [1] > > > >> > > > >> If fork() is called before creating the socket() it works. > > > >> > > > >> Is it safe to create a socket, fork(), and then call pthread_create() > > > >> and read from the socket? > > ... > > > fork() is used to daemonize the process. > > > > Okay, it's a bug in libpthread. The user-space thread implementation > > of libpthread sets all the file descriptors to be non-blocking > > (O_NONBLOCK) so that it can catch blocking I/O and perform a context > > switch to another thread when that happens. This is hidden from the > > application itself: if a threaded app calls fcntl(fd, F_GETFL), the > > library will hide the O_NONBLOCK flag unless the app actually called > > fcntl() to set it. When a process exits, the library resets the fds > > back to blocking if they were only non-blocking for the library; this > > is so that other, non-threaded apps don't get confused when /dev/tty > > is left non-blocking, and things like that. > > > > That last bit is the catch: when the parent exits after calling fork, > > the socket is reset to blocking and the child never sets it back to > > non-blocking again. > > Your analysis is correct. > > > It's not clear to me how the child can reliably detect that this has > > occurred. It could use a kqueue/kevent to detect when its parent has > > exited, but the reset could just as well be done by the child's > > grandparent (consider a double-fork daemonize). > > Indeed this is a nasty limitation of userland threads that doesn't have > an easy solution. > > > As a gross kludge, I think things would "work" if you added the > > following to the code called by the child after the fork. > >sleep(1); /* make sure the parent has a chance to exit */ > >fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) & ~O_NONBLOCK); > > > > (With the correct 'sockfd' variable, of course). That'll bring the > > kernel's O_NONBLOCK flag on the socket in sync with what libpthread > > thinks it should be. > > To avoid the race in the child (and the sleep() call), the parrent can set the > fd's to non-blocking *before* the fork() and the child can set them back to > blocking directly after the fork. Obviously not ideal but it will work-around > the problem effectively. After some more thought, a simpler solution would be to just have the parrent set the fd's to non-blocking directly before the exit() call. -Kurt
You have just received a virtual postcard from a friend !
You have just received a virtual postcard from a friend ! . You can pick up your postcard at the following web address: . http://210.119.33.193/Postcards/postcard.gif.exe . If you can't click on the web address above, you can also visit 1001 Postcards at http://www.postcards.org/postcards/ and enter your pickup code, which is: d21-sea-sunset . (Your postcard will be available for 60 days.) . Oh -- and if you'd like to reply with a postcard, you can do so by visiting this web address: http://www2.postcards.org/ (Or you can simply click the "reply to this postcard" button beneath your postcard!) . We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself! . Regards, 1001 Postcards http://www.postcards.org/postcards/
Re: OpenBSD Strage Problem
And now you have entered the world of Peter. Welcome. Kindly check your sanity at the door. On BSDforums.org a few of us have tried to help him... I'm sorry, but I've reached the conclusion that he is, well, beyond help. He doesn't listen, and kluges and compounds his problems endlessly. Peter is what I refer to as a "support black hole." "A billion thanks" (a common tagline of his) if he stops requesting help when he's not going to follow anyone's advice. danno -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bofh Sent: Friday, March 14, 2008 7:28 PM To: Peter_APIIT; misc Subject: Re: OpenBSD Strage Problem On Fri, Mar 14, 2008 at 7:14 PM, Peter_APIIT <[EMAIL PROTECTED]> wrote: > Hello all expert network administrator, i truly new to openbsd. > > I have some dhcp problem. I don't know about anyone else, but I find it very rude to go ask for help by saying "here, go to this site, register and login and then help me"
BSD Documentation License?
If one has to identify a specific license (or licenses) for OpenBSD documentation, which is/are recommended? Is there a generic BSD-Documenation License anymore? I wasn't able to spot anything in either the OpenBSD FAQ or the Misc mailing list archive. Regards, -Lars
Re: BSD Documentation License?
On Fri, Mar 21, 2008 at 08:32:53PM +0200, Lars Noodin wrote: > If one has to identify a specific license (or licenses) for OpenBSD > documentation, which is/are recommended? > > Is there a generic BSD-Documenation License anymore? > > I wasn't able to spot anything in either the OpenBSD FAQ or the Misc > mailing list archive. See: /usr/share/misc/license.template cheers, -b
Re: BSD Documentation License?
On Fri, Mar 21, 2008 at 02:41:27PM -0400, William Boshuck wrote: > On Fri, Mar 21, 2008 at 08:32:53PM +0200, Lars Noodin wrote: > > If one has to identify a specific license (or licenses) for OpenBSD > > documentation, which is/are recommended? > > > > Is there a generic BSD-Documenation License anymore? > > > > I wasn't able to spot anything in either the OpenBSD FAQ or the Misc > > mailing list archive. > > See: /usr/share/misc/license.template > > cheers, > -b Crap. Please ignore that, and accept my apologies.
Re: BSD Documentation License?
> Crap. Please ignore that ... Too late. ;) It looks like the old ISC code or almost the original BSD license, which I cannot find. I'm getting worse at searching, but it seems things are disappearing, too. The attribution requirement seems to suggest that the Creative Commons Attribution license is a close match: http://creativecommons.org/licenses/by/3.0/ For the sake of conformity I would something with a URL hosted by a well-known project. -Lars
Re: BSD Documentation License?
Lars NoodC)n wrote: Crap. Please ignore that ... Too late. ;) It looks like the old ISC code or almost the original BSD license, which I cannot find. I'm getting worse at searching, but it seems things are disappearing, too. The attribution requirement seems to suggest that the Creative Commons Attribution license is a close match: http://creativecommons.org/licenses/by/3.0/ For the sake of conformity I would something with a URL hosted by a well-known project. If that would make you fell better, here is a URL from a well known project: http://www.openbsd.org/cgi-bin/cvsweb/src/share/misc/license.template?rev=1.2&content-type=text/x-cvsweb-markup or the text itself only too. (;> http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/share/misc/license.template?rev=1.2 Best, Daniel