[lkml]   [2001]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device arguments from lookup)
    Abramo Bagnara wrote:
    > Alexander Viro wrote:
    > > Folks, before you get all excited about cramming side effects into
    > > open(2), consider the following case:
    > >
    > > 1) opening "/dev/zero/start_nuclear_war" has a certain side effect.
    > Can't this easily avoided if the needed action is not
    > < /dev/zero/start_nuclear_war
    > or
    > > /dev/zero/start_nuclear_war
    > but
    > echo "I'm evil" > /dev/zero/start_nuclear_war
    > ?

    Yes, and that is exactly the difference between having a side effect
    on the open(2), versus having the effect as a result of a write(2).

    Unfortunately, there are already some cases where an open
    on a device can have unexpected results. If you don't want
    to get blocked waiting for the carrier-detect signal from the
    modem when opening a tty device, you had better specify the
    O_NONBLOCK option on the open. If you don't want this flag
    to be active during the actual I/O operations, then you would
    have to do an fcntl to clear the O_NONBLOCK again after the open.

    So I guess things have already been a bit messy in this
    area for many years, even before linux even existed, and
    in some cases you can't really do anything about it because
    the behaviour is mandated by the applicable standards, like
    POSIX, SUS, or whatever.
    (The blocking of the open on a tty device is explicitly
    documented in my copy of the X/Open specification.)

    Fortunately, blocking the nightly backup program by making it
    accidentally open a tty is not quite as catastrophic as having
    it start a nuclear war, or format the disks, or something,
    just because a user was playing games with symlinks.

    Willem Konynenberg <>
    I am not able rightly to apprehend the kind of confusion of ideas
    that could provoke such a question -- Charles Babbage
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:53    [W:0.025 / U:25.132 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site