public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* question on tty open and close
@ 2007-03-28 11:38 Oliver Neukum
  2007-03-28 13:10 ` Stuart MacDonald
  0 siblings, 1 reply; 10+ messages in thread
From: Oliver Neukum @ 2007-03-28 11:38 UTC (permalink / raw)
  To: linux-kernel

Hi,

in tty_io.c::tty_open():

	if (!retval) {
		if (tty->driver->open)
			retval = tty->driver->open(tty, filp);
		else
			retval = -ENODEV;
	}
	filp->f_flags = saved_flags;

	if (!retval && test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
		retval = -EBUSY;

	if (retval) {
#ifdef TTY_DEBUG_HANGUP
		printk(KERN_DEBUG "error %d in opening %s...", retval,
		       tty->name);
#endif
		release_dev(filp);

We find that a failure in open() leads to release_dev() being called.
release_dev() calls close():

	if (tty->driver->close)
		tty->driver->close(tty, filp);

So we have a file that's closed although open() never succeeded?
What's the reason for that?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: question on tty open and close
@ 2007-03-28 14:37 Kilau, Scott
  0 siblings, 0 replies; 10+ messages in thread
From: Kilau, Scott @ 2007-03-28 14:37 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel

> > > > > So we have a file that's closed although open() never
succeeded?
> > > > 
> > > > That's correct! It's been a pain in my butt for years.
> > > 
> > > How did you deal with that proctological issue?
> > 
> > Just make sure the close() handles the situation properly. It makes
> > reference counting...  fun.
> > 
> > The serial driver has always handled it like this.
> 
> I'm also not aware of any reason other than history, which means if
> someone cares to double check the other drivers there really shouldn't
be
> an obstacle to "fixing" this behaviour.
> 
> Unless anyone knows different ?

Hi Alan!

>From our (Digi's) drivers history, I believe you tried "fixing" it back
in the Red Hat 7.1 days. =)

Sadly, our drivers still carry this legacy fix around.

    o Red Hat 7.1 -- Kernel Compatibility Issues
         Some 2.4 kernel-based distributions (Red Hat 7.1 included) have
a patch
         applied to them which modifies the behavior of Linux when an
open of
         a serial port is canceled (for instance, if an application is
waiting
         for the carrier signal and a user hits CTRL-C to kill the
application)
        
         With this behavior change, the device driver is unable to
cleanup its
         internal data structures and the sane functioning of the driver
is
         compromised.  The classic symptom of this problem is that the
command
         "lsmod", which (among other things) will return a count of the
         applications using the device driver, will return a non-zero
value
         even if all applications associated with the serial ports
         are killed.   
            
         Unfortunately, it is impossible (from within the device driver)
to
         determine which behavior is implemented in the running kernel.
         However, Digi now provides a workaround to allow customers with
this
         problem to change the Digi behavior to be compatible with these
         "patched" kernels.


I know backwards compatibility in the kernel isn't a concern at all,
which has been made abundantly clear, (ie, stable_api_nonsense.txt),
but this will impact *all* out of tree serial drivers.

Just wanted to toss this out there.
Scott Kilau

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-03-28 14:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 11:38 question on tty open and close Oliver Neukum
2007-03-28 13:10 ` Stuart MacDonald
2007-03-28 13:16   ` Oliver Neukum
2007-03-28 13:22     ` Stuart MacDonald
2007-03-28 14:44       ` Alan Cox
2007-03-28 15:26         ` Paul Fulghum
2007-03-28 15:31           ` Alan Cox
2007-03-28 14:54             ` Marcel Holtmann
2007-03-28 15:32             ` Paul Fulghum
  -- strict thread matches above, loose matches on Subject: below --
2007-03-28 14:37 Kilau, Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox