summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Set __EV_HUP when the conditions matching poll(2)'s POLLUP are found.mpi2020-06-151-1/+3
| | | | | | This is only done in poll-compatibility mode, when __EV_POLL is set. ok visa@, millert@
* dev/rndvar.h no longer has statistical interfaces (removed during variousderaadt2020-05-291-2/+1
| | | | | | conversion steps). it only contains kernel prototypes for 4 interfaces, all of which legitimately belong in sys/systm.h, which are already included by all enqueue_randomness() users.
* Do not wait indefinitely for flushing when closing a tty.mpi2020-05-081-6/+24
| | | | | | | | | | | This prevent exiting processes from hanging when a slave pseudo terminal is close(2)d before its master. From NetBSD via anton@. Reported-by: syzbot+2ed25b5c40d11e4c3beb@syzkaller.appspotmail.com ok anton@, kettenis@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-4/+4
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-3/+3
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Replace ttkqflush() with klist_invalidate() to handle knote listvisa2020-02-081-46/+11
| | | | | | | | invalidation in one place. Store struct tty pointer in kn_hook directly to simplify the code. OK mpi@
* Convert sleeps of 1sec or more to tsleep_nsec(9).mpi2020-01-091-2/+3
| | | | ok bluhm@
* Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP andvisa2020-01-081-1/+29
| | | | | | | | | | | | FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of the ID parameter inside the sigio code. Also add cases for FIOSETOWN and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before. These changes allow removing the ID translation from sys_fcntl() and sys_ioctl(). Idea from NetBSD OK mpi@, claudio@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-5/+14
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* ttysleep(): drop unused timeout parametercheloha2019-07-191-11/+11
| | | | | | | | All callers sleep indefinitely. With help from visa@. ok visa@, ratchov@, kn@
* Use timeout_add_msec(9)kn2019-07-091-19/+12
| | | | | | | | | | | | | | | | | | | As per termios(4), "VTIME is a timer of 0.1 second granularity", so convert it to milliseconds by reducing by hz and multiplying with 1000. Furthermore, the specification (and our implementation) define members of the c_cc arry to be of type unsigned char, so both the previous as well as the now used arithmetic operations are guaranteed to not overflow. Since the timeout_add(9) API takes an int argument, the previous long type would always be demoted anyway, so change it to int directly. With this and hz gone, remove the obselete comment. While here, use more mnemonic variable names. Feedback and OK mpi
* Revert to using the SCHED_LOCK() to protect time accounting.mpi2019-06-011-3/+1
| | | | | | | | | It currently creates a lock ordering problem because SCHED_LOCK() is taken by hardclock(). That means the "priorities" of a thread should be moved out of the SCHED_LOCK() first in order to make progress. Reported-by: syzbot+8e4863b3dde88eb706dc@syzkaller.appspotmail.com via anton@ as well as by kettenis@
* Use a per-process mutex to protect time accounting instead of SCHED_LOCK().mpi2019-05-311-1/+3
| | | | | | | Note that hardclock(9) still increments p_{u,s,i}ticks without holding a lock. ok visa@, cheloha@
* When killing a process, the signal is handled by any thread thatbluhm2019-05-131-3/+3
| | | | | | | | | | does not block the signal. If all threads block the signal, we delivered it to the main thread. This does not conform to POSIX. If any thread unblocks the signal, it should be delivered immediately to this thread. Mark such signals pending at the process instead of a single thread. Then any thread can handle it later. OK kettenis@ guenther@
* fix whitespacejsg2018-09-061-3/+3
|
* Decouple unveil from the pledge flags, by adding dedicated unveil flagsbeck2018-08-051-1/+2
| | | | | | | | to the namei args. This fixes a bug where chmod would be allowed when with only READ. This also allows some further cleanup of some awkward things like PLEDGE_STAT that will follow Lots of assistence from semarie@ - thanks! ok semarie@
* base and ports are now clean of TIOCSTI uses. The #define can now be removed.deraadt2018-06-161-4/+1
| | | | | | The code was already changed to return EIO, it will now return ENOTTY since the code is deleted. ok sthen
* Remove proc from the parameters of vn_lock(). The parameter isvisa2018-05-021-2/+2
| | | | | | unnecessary because curproc always does the locking. OK mpi@
* replace add_*_randomness with enqueue_randomness()jasper2018-04-281-2/+2
| | | | | | | | | this gets rid of the source annotation which doesn't really add anything other than adding complexitiy. randomess is generally good enough that the few extra bits that the source type would add are not worth it. ok mikeb@ deraadt@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-281-2/+2
| | | | | | | curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-2/+2
| | | | | | | The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
* reduce scope of variable a bit to avoid shadowingtedu2018-02-061-2/+3
|
* Don't pull in <sys/file.h> just to get fcntl.hguenther2017-12-301-2/+2
| | | | ok deraadt@ krw@
* Due to risks known for decades, TIOCSTI now performs no action, and simplyderaadt2017-06-291-7/+2
| | | | | | | | returns EIO. The base system has been cleaned of TIOCSTI uses (collaboration between anton and I), and the ports tree appears mostly clean. A few stragglers may be discovered and cleaned up later... In a month or so, we should see if the #define can be removed entirely. ok anton tedu, support from millert
* p_comm is the process's command and isn't per thread, so move it fromguenther2017-01-211-2/+2
| | | | | | struct proc to struct process. ok deraadt@ kettenis@
* POSIX specifies that if a processing calling tcsetpgrp() is in themillert2016-07-101-3/+1
| | | | | background it shall receive SIGTTOU. Handle TIOCSPGRP like we do the other tty ioctls that change the terminal. OK deraadt@ guenther@
* Allow sendsyslog(2) with LOG_CONS even when /dev/console has notbluhm2016-05-171-4/+1
| | | | | | | been opened during init(8). Only log with cnwrite() if cn_devvp exists, otherwise use cnputc() as fallback. While there move extern declarations to dev/cons.h. input and OK deraadt@
* Remove the unused flags argument from VOP_UNLOCK().natano2016-03-191-2/+2
| | | | | | torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
* Convert to uiomove. Diff from Martin Natano.stefan2016-01-281-2/+2
|
* Increase buffer sizes and watermarks for tty and pppsf2016-01-141-2/+7
| | | | | | | | | | | | | | | | Use 115200 the default speed for buffer sizing in ttymalloc(). A lot of devices call ttymalloc(0) so this affects quite a few of them. Increases the buffer size for 9600 < baud <= 115200 from 1k to 4k. Make ppp use the lo/hi watermarks from the tty layer which are adjusted according to speed + buffer size. The previous fixed values of 100 and 400 were way too small Make pty call ttymalloc() with baud == 1000000, which is the common value used in the tree for "fast". ok deraadt@
* remove stale lint annotationstedu2015-12-051-2/+1
|
* move the pledgenote annotation from `struct proc' to `struct nameidata'semarie2015-11-021-2/+2
| | | | | | | | | | pledgenote is used for annotate the policy for a namei context. So make it tracking the nameidata. It is expected for the caller to explicitly define the policy. It is a kernel bug to not do so. ok deraadt@
* TIOCCONS will probably never be permitted, but it is good style to setderaadt2015-10-281-1/+3
| | | | p_pledgenote before NDINIT()
* Modify ttystats_init() to tell us about the buffer size, so that wederaadt2015-08-281-5/+7
| | | | can pass the size to free()
* two simple free() sizesderaadt2015-08-261-3/+3
|
* Fix tty hiwat handling a bitsf2015-07-201-14/+5
| | | | | | | | | | | | | - Introduce new defines TTHIWATMINSPACE, TTMINHIWAT for some magic values that are used in tty.c. - Remove hiwat adjustments in ttwrite(). This fixes this codepath not being interrupt safe. - Change ttysetwater() to keep at least TTHIWATMINSPACE space above the high water mark. This makes it consistent with ttycheckoutq(). Without this change, the hiwat adjustment change above causes deadlocks in pty. ok kspillner@ commit it now deraadt@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-2/+2
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* Add dmesg -s support, to view the output of rc(8) system startup messages.mpf2015-01-131-1/+14
| | | | | Help and feedback by Theo and Miod. OK deraadt@, manpage-ok jmc@
* remove lock.h from uvm_extern.h. another holdover from the simpletonlocktedu2014-12-171-1/+2
| | | | | era. fix uvm including c files to include lock.h or atomic.h as necessary. ok deraadt
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-1/+3
| | | | | | objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
* convert bcopy to memcpy. ok millerttedu2014-12-101-4/+4
|
* clist's chained, and could get fairly long which is why there was aderaadt2014-12-011-4/+3
| | | | | | | | | | dynamic clamping mechanism. In the (new? has it already been 20 years?) world of tty ring buffers, c_cn is the maximum... There could be some ugly limit elsewhere, which may cause a deadlock (dug as deep as my patience allows), so please report any sort of new console or xterm issues that show up, such as tty lockups or high cpu utilization..
* include unistd.h instead of picking it up accidentally. noted by jsgtedu2014-11-181-1/+2
|
* Remove non-standard <sys/dkstat.h> header. It has not contained anythingmiod2014-09-151-2/+1
| | | | | | | | | | related to disk stastics for almost 17 years, and the remaining userland-visible defines duplicate those found in <sys/sched.h>. Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and update all users to cope with this. ok kettenis@
* use mallocarray where arguments are multipled. ok deraadttedu2014-07-131-2/+2
|
* If the only process in the pgrp is in the middle of exiting, it mightguenther2014-07-131-2/+4
| | | | | | not have any threads left. Treat that the same as an empty pgrp. encountered by and ok deraadt@
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-4/+4
| | | | after discussions with beck deraadt kettenis.
* decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hderaadt2014-07-081-2/+1
| | | | | don't need to be married. ok guenther miod beck jsing kettenis
* Track whether a process is a zombie or not yet fully built via flagsguenther2014-07-041-4/+3
| | | | | | | | | | | PS_{ZOMBIE,EMBRYO} on the process instead of peeking into the process's thread data. This eliminates the need for the thread-level SDEAD state. Change kvm_getprocs() (both the sysctl() and kvm backends) to report the "most active" scheduler state for the process's threads. tweaks kettenis@ feedback and ok matthew@
* Allocate the struct itty array in ttystats_init() with M_ZERO.matthew2014-06-061-2/+2
| | | | ok millert