1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

Add ioctl() and reimplement tcsetpgrp/tcsetpgrp as ioctls.

This commit is contained in:
Andreas Kling 2018-11-16 13:11:21 +01:00
parent 2529925fe9
commit c99f8af66d
16 changed files with 94 additions and 45 deletions

View file

@ -1,6 +1,8 @@
#include "TTY.h"
#include "Process.h"
#include <LibC/errno_numbers.h>
#include <LibC/signal_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
TTY::TTY(unsigned major, unsigned minor)
: CharacterDevice(major, minor)
@ -66,3 +68,22 @@ void TTY::set_termios(const Unix::termios& t)
should_echo_input(),
should_generate_signals());
}
int TTY::ioctl(Process& process, unsigned request, unsigned arg)
{
if (process.tty() != this)
return -ENOTTY;
switch (request) {
case TIOCGPGRP:
return pgid();
case TIOCSPGRP: {
// FIXME: Validate pgid fully.
pid_t pgid = static_cast<pid_t>(arg);
if (pgid < 0)
return -EINVAL;
set_pgid(arg);
return 0;
}
}
return -EINVAL;
}