From owner-freebsd-current Mon Dec 7 06:10:45 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA01393 for freebsd-current-outgoing; Mon, 7 Dec 1998 06:10:45 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from highwind.com (hurricane.highwind.com [209.61.45.50]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA01388 for ; Mon, 7 Dec 1998 06:10:40 -0800 (PST) (envelope-from info@highwind.com) Received: (from info@localhost) by highwind.com (8.8.6/8.8.6) id JAA17159; Mon, 7 Dec 1998 09:10:34 -0500 (EST) Date: Mon, 7 Dec 1998 09:10:34 -0500 (EST) Message-Id: <199812071410.JAA17159@highwind.com> From: HighWind Software Information To: current@FreeBSD.ORG Subject: Re: Thread fd locking and fork() Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Terry, First, since this is POSIX thread fork() semantics, you don't get a copy of all threads when you fork(). You just get the thread that called fork(). At least, that is the way it should work and appears to work. Second, I don't see why it is bad for a threaded program to call fork(). Why not? What if you need to exec() sendmail or some other helper program? Third, I still don't see why my patch is bad. After fork(), you have one thread left. It makes no sense for the remaining fd's that are open to be locked by threads that do not exist! If they are simply unlocked/cleaned up in the child, the child is then free to close() or manipulate those fd's. This is the way it works on every other O/S. You can always: fork(), then in the child, loop over fd's to close() the one's you want to close(), then exec() a program. -Rob -- Insert in uthread_fork.c at line 122: /* * Enter a loop to remove all locks on all locked fd's */ for (i = 0; i < _thread_dtablesize; i++) { if (_thread_fd_table[i] != NULL) { memset(&_thread_fd_table[i]->lock, 0, sizeof(_thread_fd_table[i]->lock)); _thread_fd_table[i]->r_owner = NULL; _thread_fd_table[i]->w_owner = NULL; _thread_fd_table[i]->r_fname = NULL; _thread_fd_table[i]->w_fname = NULL; _thread_fd_table[i]->r_lineno = 0;; _thread_fd_table[i]->w_lineno = 0;; _thread_fd_table[i]->r_lockcount = 0; _thread_fd_table[i]->w_lockcount = 0; /* Initialise the read/write queues: */ _thread_queue_init(&_thread_fd_table[i]->r_queu\ e); _thread_queue_init(&_thread_fd_table[i]->w_queu\ e); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message