Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262257AbTFDAoi (ORCPT ); Tue, 3 Jun 2003 20:44:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262340AbTFDAoi (ORCPT ); Tue, 3 Jun 2003 20:44:38 -0400 Received: from spanner.eng.cam.ac.uk ([129.169.8.9]:24263 "EHLO spanner.eng.cam.ac.uk") by vger.kernel.org with ESMTP id S262257AbTFDAoh (ORCPT ); Tue, 3 Jun 2003 20:44:37 -0400 Date: Wed, 4 Jun 2003 01:58:02 +0100 (BST) From: "P. Benie" To: Linus Torvalds cc: Kernel Mailing List Subject: [PATCH] [2.5] Non-blocking write can block Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 903 Lines: 29 Non-blocking writes to a tty will block if there is a blocking write waiting for the atomic_write semaphore. Peter --- linux-2.5.70/drivers/char/tty_io.c.orig 2003-06-03 21:34:42.000000000 +0100 +++ linux-2.5.70/drivers/char/tty_io.c 2003-06-04 01:40:33.000000000 +0100 @@ -687,8 +687,13 @@ { ssize_t ret = 0, written = 0; - if (down_interruptible(&tty->atomic_write)) { - return -ERESTARTSYS; + if (file->f_flags & O_NONBLOCK) { + if (down_trylock(&tty->atomic_write)) + return -EAGAIN; + } + else { + if (down_interruptible(&tty->atomic_write)) + return -ERESTARTSYS; } if ( test_bit(TTY_NO_WRITE_SPLIT, &tty->flags) ) { lock_kernel(); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/