Coreutils timeout(1) plays badly with man/less
I want to set a timeout to the less(1)
command on our company's production server. Everyday we produce large log files on it, and despite the nightly batch job to archive/remove them, we sometimes get alerted on high disk usage because a (long-)running process can prevent a file from getting unlink(2)
-ed physically due to the reference-counting semantics of POSIX filesystems.
To avoid the most common cases of such annoyances, I wrote a wrapper of less
which runs it under timeout(1)
so that idle less
processes get automatically killed after several hours without keeping open files in the filesystem.
But it turned out to play badly with man(1)
: when the wrapper is launched by the man
command via the PAGER
environment variable, it stopped responding to any keyboard inputs. Here is a minimal reproducible test case:
$ PAGER='timeout 12h /bin/less' man man
After running this, ps fx
output looks like this:
19415 pts/1 SNs 0:00 _ -bash
19854 pts/1 SN+ 0:00 _ man man
19867 pts/1 SN 0:00 _ timeout 12h /bin/less
19869 pts/1 TN 0:00 _ /bin/less
and I could only kill -KILL 19869
to regain an access to the terminal.
What did I get wrong here?
Why is the less
process in the T
state, as opposed to S
?
terminal process-management timeout
add a comment |
I want to set a timeout to the less(1)
command on our company's production server. Everyday we produce large log files on it, and despite the nightly batch job to archive/remove them, we sometimes get alerted on high disk usage because a (long-)running process can prevent a file from getting unlink(2)
-ed physically due to the reference-counting semantics of POSIX filesystems.
To avoid the most common cases of such annoyances, I wrote a wrapper of less
which runs it under timeout(1)
so that idle less
processes get automatically killed after several hours without keeping open files in the filesystem.
But it turned out to play badly with man(1)
: when the wrapper is launched by the man
command via the PAGER
environment variable, it stopped responding to any keyboard inputs. Here is a minimal reproducible test case:
$ PAGER='timeout 12h /bin/less' man man
After running this, ps fx
output looks like this:
19415 pts/1 SNs 0:00 _ -bash
19854 pts/1 SN+ 0:00 _ man man
19867 pts/1 SN 0:00 _ timeout 12h /bin/less
19869 pts/1 TN 0:00 _ /bin/less
and I could only kill -KILL 19869
to regain an access to the terminal.
What did I get wrong here?
Why is the less
process in the T
state, as opposed to S
?
terminal process-management timeout
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
The only way I can reproduce this is if I temporarily putman
/less
in the background throughCtrl+Z
. Did you do that to run yourps
command? That would putless
in a T state... Usingtimeout
inPAGER
seems to work as expected on my OpenBSD system.
– Kusalananda
17 mins ago
add a comment |
I want to set a timeout to the less(1)
command on our company's production server. Everyday we produce large log files on it, and despite the nightly batch job to archive/remove them, we sometimes get alerted on high disk usage because a (long-)running process can prevent a file from getting unlink(2)
-ed physically due to the reference-counting semantics of POSIX filesystems.
To avoid the most common cases of such annoyances, I wrote a wrapper of less
which runs it under timeout(1)
so that idle less
processes get automatically killed after several hours without keeping open files in the filesystem.
But it turned out to play badly with man(1)
: when the wrapper is launched by the man
command via the PAGER
environment variable, it stopped responding to any keyboard inputs. Here is a minimal reproducible test case:
$ PAGER='timeout 12h /bin/less' man man
After running this, ps fx
output looks like this:
19415 pts/1 SNs 0:00 _ -bash
19854 pts/1 SN+ 0:00 _ man man
19867 pts/1 SN 0:00 _ timeout 12h /bin/less
19869 pts/1 TN 0:00 _ /bin/less
and I could only kill -KILL 19869
to regain an access to the terminal.
What did I get wrong here?
Why is the less
process in the T
state, as opposed to S
?
terminal process-management timeout
I want to set a timeout to the less(1)
command on our company's production server. Everyday we produce large log files on it, and despite the nightly batch job to archive/remove them, we sometimes get alerted on high disk usage because a (long-)running process can prevent a file from getting unlink(2)
-ed physically due to the reference-counting semantics of POSIX filesystems.
To avoid the most common cases of such annoyances, I wrote a wrapper of less
which runs it under timeout(1)
so that idle less
processes get automatically killed after several hours without keeping open files in the filesystem.
But it turned out to play badly with man(1)
: when the wrapper is launched by the man
command via the PAGER
environment variable, it stopped responding to any keyboard inputs. Here is a minimal reproducible test case:
$ PAGER='timeout 12h /bin/less' man man
After running this, ps fx
output looks like this:
19415 pts/1 SNs 0:00 _ -bash
19854 pts/1 SN+ 0:00 _ man man
19867 pts/1 SN 0:00 _ timeout 12h /bin/less
19869 pts/1 TN 0:00 _ /bin/less
and I could only kill -KILL 19869
to regain an access to the terminal.
What did I get wrong here?
Why is the less
process in the T
state, as opposed to S
?
terminal process-management timeout
terminal process-management timeout
asked 26 mins ago
nodakai
21719
21719
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
The only way I can reproduce this is if I temporarily putman
/less
in the background throughCtrl+Z
. Did you do that to run yourps
command? That would putless
in a T state... Usingtimeout
inPAGER
seems to work as expected on my OpenBSD system.
– Kusalananda
17 mins ago
add a comment |
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
The only way I can reproduce this is if I temporarily putman
/less
in the background throughCtrl+Z
. Did you do that to run yourps
command? That would putless
in a T state... Usingtimeout
inPAGER
seems to work as expected on my OpenBSD system.
– Kusalananda
17 mins ago
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
The only way I can reproduce this is if I temporarily put
man
/less
in the background through Ctrl+Z
. Did you do that to run your ps
command? That would put less
in a T state... Using timeout
in PAGER
seems to work as expected on my OpenBSD system.– Kusalananda
17 mins ago
The only way I can reproduce this is if I temporarily put
man
/less
in the background through Ctrl+Z
. Did you do that to run your ps
command? That would put less
in a T state... Using timeout
in PAGER
seems to work as expected on my OpenBSD system.– Kusalananda
17 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492941%2fcoreutils-timeout1-plays-badly-with-man-less%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492941%2fcoreutils-timeout1-plays-badly-with-man-less%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Show us the wrapper please
– Rui F Ribeiro
20 mins ago
The only way I can reproduce this is if I temporarily put
man
/less
in the background throughCtrl+Z
. Did you do that to run yourps
command? That would putless
in a T state... Usingtimeout
inPAGER
seems to work as expected on my OpenBSD system.– Kusalananda
17 mins ago