tail: Use pledge()

This commit is contained in:
Brian Gianforcaro 2020-01-12 16:11:47 -08:00 committed by Andreas Kling
parent 0c44a12247
commit 70defb34e6
Notes: sideshowbarker 2024-07-19 10:06:33 +09:00

View File

@ -70,6 +70,11 @@ off_t find_seek_pos(CFile& file, int wanted_lines)
int main(int argc, char* argv[])
{
if (pledge("stdio rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
CArgsParser args_parser("tail");
args_parser.add_arg("f", "follow -- appended data is output as it is written to the file");
@ -101,6 +106,11 @@ int main(int argc, char* argv[])
exit(1);
}
if (pledge("stdio", nullptr) < 0) {
perror("pledge");
return 1;
}
bool flag_follow = args.is_present("f");
auto pos = find_seek_pos(*f, line_count);
return tail_from_pos(*f, pos, flag_follow);