chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
terminal-util: no real reason to assert on O_CREAT
[elogind.git]
/
src
/
basic
/
terminal-util.c
diff --git
a/src/basic/terminal-util.c
b/src/basic/terminal-util.c
index 3c473dc92668139ae2cc6a6d7a8be818b8cccefc..28ae5dc08bd9dd0ff8e6269909e8ef6c729036c2 100644
(file)
--- a/
src/basic/terminal-util.c
+++ b/
src/basic/terminal-util.c
@@
-44,7
+44,7
@@
static volatile unsigned cached_lines = 0;
int chvt(int vt) {
_cleanup_close_ int fd;
int chvt(int vt) {
_cleanup_close_ int fd;
- fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
+ fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC
|O_NONBLOCK
);
if (fd < 0)
return -errno;
if (fd < 0)
return -errno;
@@
-287,7
+287,11
@@
finish:
int reset_terminal(const char *name) {
_cleanup_close_ int fd = -1;
int reset_terminal(const char *name) {
_cleanup_close_ int fd = -1;
- fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC);
+ /* We open the terminal with O_NONBLOCK here, to ensure we
+ * don't block on carrier if this is a terminal with carrier
+ * configured. */
+
+ fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)
return fd;
if (fd < 0)
return fd;
@@
-307,7
+311,8
@@
int open_terminal(const char *name, int mode) {
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
*/
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
*/
- assert(!(mode & O_CREAT));
+ if (mode & O_CREAT)
+ return -EINVAL;
for (;;) {
fd = open(name, mode, 0);
for (;;) {
fd = open(name, mode, 0);
@@
-504,7
+509,7
@@
int release_terminal(void) {
struct sigaction sa_old;
int r = 0;
struct sigaction sa_old;
int r = 0;
- fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_
NDELAY|O_CLOEXEC
);
+ fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_
CLOEXEC|O_NONBLOCK
);
if (fd < 0)
return -errno;
if (fd < 0)
return -errno;
@@
-533,7
+538,7
@@
int terminal_vhangup_fd(int fd) {
int terminal_vhangup(const char *name) {
_cleanup_close_ int fd;
int terminal_vhangup(const char *name) {
_cleanup_close_ int fd;
- fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC);
+ fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC
|O_NONBLOCK
);
if (fd < 0)
return fd;
if (fd < 0)
return fd;
@@
-580,7
+585,7
@@
int vt_disallocate(const char *name) {
return -EINVAL;
/* Try to deallocate */
return -EINVAL;
/* Try to deallocate */
- fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
+ fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC
|O_NONBLOCK
);
if (fd < 0)
return fd;
if (fd < 0)
return fd;