tools: libsubcmd: Drop the less hack that was inherited from Git.
PATCH 1/1 tools: libsubcmd: Drop the less hack that was inherited from Git.
We inherited this hack with the original code from the Git project. The select call is invalid as the two fd_set pointers should not be aliased.
We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
--- tools/lib/subcmd/pager.c | 17 ----------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 20 deletions(-)
tools/lib/subcmd/pager.c +0 -17
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h>
@@ -23,21 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; - -FD_ZERO (&in); -FD_SET (0 , &in); -select (1 , &in,NULL , &in,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;
@@ -84,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;
tools/lib/subcmd/run-command.c +0 -2
@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {
tools/lib/subcmd/run-command.h +0 -1
@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);
Signature · 1 line
2.13.6
Quoted 10 lines · Arvind Sankar
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Signed-off-by Arvind Sankar <[email protected]>
Looks good to me.
Libsubcmd is used by perf and objtool, so adding the perf maintainers to CC. Arnaldo, do you want to pick this one up?
Quoted 74 lines
--- tools/lib/subcmd/pager.c | 17 ----------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 20 deletions(-)tools/lib/subcmd/pager.c +0
-17@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,21 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; - -FD_ZERO (&in); -FD_SET (0 , &in); -select (1 , &in,NULL , &in,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -84,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run-command.h +0
-1@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);Signature · 1 line
2.13.6
Signature · 1 line
Josh
Em Wed, Jan 24, 2018 at 02:54:11PM -0600, Josh Poimboeuf escreveu:
Quoted 10 lines · Arvind Sankar
Quoted 9 lines
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Quoted 8 lines
Quoted 1 line
Signed-off-by Arvind Sankar <[email protected]>Looks good to me.
Acked-by Josh Poimboeuf <[email protected]>Libsubcmd is used by perf and objtool, so adding the perf maintainers to CC. Arnaldo, do you want to pick this one up?
Sure, I'll put it in my perf/core branch.
- Arnaldo
Quoted 77 lines
Quoted 74 lines
--- tools/lib/subcmd/pager.c | 17 ----------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 20 deletions(-)tools/lib/subcmd/pager.c +0
-17@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,21 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; - -FD_ZERO (&in); -FD_SET (0 , &in); -select (1 , &in,NULL , &in,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -84,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run-command.h +0
-1@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);Signature · 1 line
2.13.6Signature · 1 line
Josh
Thanks.
This was found because gcc 8 appears to be enabling -Wrestrict in -Wall, so there is a build failure with mainline gcc.
Quoted 101 lines · Arnaldo Carvalho de Melo
Em Wed, Jan 24, 2018 at 02:54:11PM -0600, Josh Poimboeuf escreveu:
Quoted 10 lines · Arvind Sankar
Quoted 9 lines
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Quoted 8 lines
Quoted 1 line
Signed-off-by Arvind Sankar <[email protected]>Looks good to me.
Acked-by Josh Poimboeuf <[email protected]>Libsubcmd is used by perf and objtool, so adding the perf maintainers to CC. Arnaldo, do you want to pick this one up?
Sure, I'll put it in my perf/core branch.
- Arnaldo
Quoted 77 lines
Quoted 74 lines
--- tools/lib/subcmd/pager.c | 17 ----------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 20 deletions(-)tools/lib/subcmd/pager.c +0
-17@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,21 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; - -FD_ZERO (&in); -FD_SET (0 , &in); -select (1 , &in,NULL , &in,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -84,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run-command.h +0
-1@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);Signature · 1 line
2.13.6Signature · 1 line
Josh
Hi, it looks like Sergey has put in a patch to fix the aliasing, looking at the linux-next tree.
Are we still looking to remove this hack altogether?
Thanks
Quoted 107 lines · Arvind Sankar
Thanks.
This was found because gcc 8 appears to be enabling -Wrestrict in -Wall, so there is a build failure with mainline gcc.
Quoted 101 lines · Arnaldo Carvalho de Melo
Em Wed, Jan 24, 2018 at 02:54:11PM -0600, Josh Poimboeuf escreveu:
Quoted 10 lines · Arvind Sankar
Quoted 9 lines
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Quoted 8 lines
Quoted 1 line
Signed-off-by Arvind Sankar <[email protected]>Looks good to me.
Acked-by Josh Poimboeuf <[email protected]>Libsubcmd is used by perf and objtool, so adding the perf maintainers to CC. Arnaldo, do you want to pick this one up?
Sure, I'll put it in my perf/core branch.
- Arnaldo
Quoted 77 lines
Quoted 74 lines
--- tools/lib/subcmd/pager.c | 17 ----------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 20 deletions(-)tools/lib/subcmd/pager.c +0
-17@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,21 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; - -FD_ZERO (&in); -FD_SET (0 , &in); -select (1 , &in,NULL , &in,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -84,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run-command.h +0
-1@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);Signature · 1 line
2.13.6Signature · 1 line
Josh
We inherited this hack with the original code from the Git project. The select call is invalid as the two fd_set pointers should not be aliased.
We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
---
- Merge with commit ad343a98 (tools/lib/subcmd/pager.c: do not alias select() params) by Sergey
tools/lib/subcmd/pager.c | 20 -------------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 23 deletions(-)
tools/lib/subcmd/pager.c +0 -20
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h>
@@ -23,24 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; -fd_set exception; - -FD_ZERO (&in); -FD_ZERO (&exception); -FD_SET (0 , &in); -FD_SET (0 , &exception); -select (1 , &in,NULL , &exception,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;
@@ -87,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;
tools/lib/subcmd/run-command.c +0 -2
@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {
tools/lib/subcmd/run-command.h +0 -1
@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);
Signature · 1 line
2.13.6
Em Thu, Feb 08, 2018 at 07:00:10PM -0500, Arvind Sankar escreveu:
Quoted 8 lines
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Ok, so e8320f3 was merged directly by Linus, I'll wait till perf/urgent pulls from upstream and then will merge this,
Thanks,
- Arnaldo
Quoted 80 lines
Signed-off-by Arvind Sankar <[email protected]>---
- Merge with commitad343a98(tools/lib/subcmd/pager.c: do not aliasselect()params) by Sergeytools/lib/subcmd/pager.c | 20 -------------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 23 deletions(-)tools/lib/subcmd/pager.c +0
-20@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,24 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; -fd_set exception; - -FD_ZERO (&in); -FD_ZERO (&exception); -FD_SET (0 , &in); -FD_SET (0 , &exception); -select (1 , &in,NULL , &exception,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -87,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run-command.h +0
-1@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *);Signature · 1 line
2.13.6
Hey did this ever make it in?
Quoted 100 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 08, 2018 at 07:00:10PM -0500, Arvind Sankar escreveu:
Quoted 8 lines
We inherited this hack with the original code from the Git project. The select call is invalid as the two
fd_setpointers should not be aliased.We could fix it, but the Git project removed this hack in 2012 in commit e8320f3 (pager: drop "wait for output to run less" hack). The bug it worked around was apparently fixed in less back in June 2007.
So remove the hack from here as well.
Ok, so e8320f3 was merged directly by Linus, I'll wait till perf/urgent pulls from upstream and then will merge this,
Thanks,
- Arnaldo
tools/lib/subcmd/run-
Quoted 54 lines
Signed-off-by Arvind Sankar <[email protected]>---
- Merge with commitad343a98(tools/lib/subcmd/pager.c: do not aliasselect()params) by Sergeytools/lib/subcmd/pager.c | 20 -------------------- tools/lib/subcmd/run-command.c | 2 -- tools/lib/subcmd/run-command.h | 1 - 3 files changed, 23 deletions(-)tools/lib/subcmd/pager.c +0
-20@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <sys/select.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -23,24 +22,6 @@ void pager_init(const char *pager_env) subcmd_config.pager_env = pager_env; } -static void pager_preexec (void ) -{ -/* -* Work around bug in "less" by not starting it until we -* have real input -*/ -fd_set in; -fd_set exception; - -FD_ZERO (&in); -FD_ZERO (&exception); -FD_SET (0 , &in); -FD_SET (0 , &exception); -select (1 , &in,NULL , &exception,NULL ); - -setenv ("LESS" ,"FRSX" ,0 ); -} -static const char *pager_argv[] = {"sh" ,"-c" ,NULL ,NULL };static struct child_process pager_process;@@ -87,7 +68,6 @@ void setup_pager(void) pager_argv[2 ] = pager; pager_process.argv = pager_argv; pager_process.in =-1 ; - pager_process.preexec_cb = pager_preexec;if (start_command (&pager_process))return ;tools/lib/subcmd/run- renamed from tools/lib/subcmd/run-command.c +0
-0
command.ctools/lib/subcmd/run-
Quoted 13 lines
index
5cdac2162532..9e9dca717ed7100644tools/lib/subcmd/run-command.c +0
-2@@ -120,8 +120,6 @@ int start_command(struct child_process *cmd)unsetenv (*cmd->env); } } -if (cmd->preexec_cb) - cmd->preexec_cb ();if (cmd->exec_cmd) {execv_cmd (cmd->argv); }else {tools/lib/subcmd/run- renamed from tools/lib/subcmd/run-command.h +0
-0
command.hQuoted 13 lines
index
17d969c6add3..6256268802b5100644tools/lib/subcmd/run-command.h +0
-2@@ -46,7 +46,6 @@ struct child_process { unsigned no_stderr:1; unsigned exec_cmd:1; /* if this is to be external sub-command */ unsigned stdout_to_stderr:1; -void (*preexec_cb)(void ); };int start_command (struct child_process *); --2.13.6