kconf: Check for eof from input stream.
PATCH 15/15 kconf: Check for eof from input stream.
---
scripts/kconfig/conf.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
62bb36dcb307ca53999a14f74da6a803e36d5f62
scripts/kconfig/conf.c +16 -2
@@ -63,6 +63,20 @@ static void check_stdin(void) } } +static char *fgets_check_stream (char *s,int size,FILE *stream) +{ +char *ret =fgets (s, size, stream); + +if (ret ==NULL &&feof (stream)) { +printf (_ ("aborted!\n\n" )); +printf (_ ("Console input is closed. " )); +printf (_ ("Run 'make oldconfig' to update configuration.\n\n" )); +exit (1 ); + } + +return ret; +} +static void conf_askvalue (struct symbol *sym,const char *def) {enum symbol_type type =sym_get_type (sym);
@@ -100,7 +114,7 @@ static void conf_askvalue(struct symbolcheck_stdin ();case ask_all:fflush (stdout); -fgets (line,128 , stdin); +fgets_check_stream (line,128 , stdin);return ;case set_default:printf ("%s\n" , def);
@@ -356,7 +370,7 @@ static int conf_choice(struct menu *menucheck_stdin ();case ask_all:fflush (stdout); -fgets (line,128 , stdin); +fgets_check_stream (line,128 , stdin);strip (line);if (line[0 ] =='?' ) { printf("\n%s\n", menu->sym->help ?
Signature · 1 line
1.0.5
Hi,
scripts/kconfig/conf.c static void check_stdin(void) · line 78
Quoted 13 lines · Ben Collins
scripts/kconfig/conf.c +13
-0+static char *fgets_check_stream (char *s,int size,FILE *stream) +{ +char *ret =fgets (s, size, stream); + +if (ret ==NULL &&feof (stream)) { +printf (_ ("aborted!\n\n" )); +printf (_ ("Console input is closed. " )); +printf (_ ("Run 'make oldconfig' to update configuration.\n\n" )); +exit (1 ); + } + +return ret; +}
What problem does this solve? conf should finish normally anyway and just set everything to the default.
bye, Roman
Quoted 4 lines · Roman Zippel
Hi,
On Wednesday 04 January 2006 23:01, Ben Collins wrote:
Quoted 16 lines
scripts/kconfig/conf.c static void check_stdin(void) · line 78
Quoted 13 lines
scripts/kconfig/conf.c +13
-0+static char *fgets_check_stream (char *s,int size,FILE *stream) +{ +char *ret =fgets (s, size, stream); + +if (ret ==NULL &&feof (stream)) { +printf (_ ("aborted!\n\n" )); +printf (_ ("Console input is closed. " )); +printf (_ ("Run 'make oldconfig' to update configuration.\n\n" )); +exit (1 ); + } + +return ret; +}What problem does this solve? conf should finish normally anyway and just set everything to the default.
It shouldn't, and it doesn't (that's what defconfig does, I believe).
Anyway, the problem is that if there is no terminal (e.g. stdout is redirected to a file, and stdin is closed), then kconf loops forever trying to get an answer (NULL is not the same as "").
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 3 lines · Ben Collins
Anyway, the problem is that if there is no terminal (e.g. stdout is redirected to a file, and stdin is closed), then kconf loops forever trying to get an answer (NULL is not the same as "").
Then let's fix the real problem.
bye, Roman
scripts/kconfig/conf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)scripts/kconfig/conf.c +1 -2
@@ -314,8 +314,7 @@ static int conf_choice(struct menu *menuprintf ("%*s%s\n" , indent -1 ,"" ,menu_get_prompt (menu)); def_sym =sym_get_choice_value (sym); cnt = def =0 ; - line[0 ] ='0' ; - line[1 ] =0 ; + line[0 ] =0 ;for (child = menu->list; child; child = child->next) {if (!menu_is_visible (child))continue ;
Quoted 9 lines · Roman Zippel
Hi,
Quoted 3 lines · Ben Collins
Anyway, the problem is that if there is no terminal (e.g. stdout is redirected to a file, and stdin is closed), then kconf loops forever trying to get an answer (NULL is not the same as "").
Then let's fix the real problem.
That's not entirely acceptable. The reason this shows up is if an automatic build is being done, and the config files are not up-to-date, the prefered action is a build failure, not selecting defaults. The reason for my fix was that instead of filling up diskspace with a logfile of kconf's infinite loop, we just exit with an error.
Currently, this is the only way to ensure that these issues don't go unnoticed.
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 8 lines · Ben Collins
That's not entirely acceptable. The reason this shows up is if an automatic build is being done, and the config files are not up-to-date, the prefered action is a build failure, not selecting defaults. The reason for my fix was that instead of filling up diskspace with a logfile of kconf's infinite loop, we just exit with an error.
Currently, this is the only way to ensure that these issues don't go unnoticed.
Then something is wrong with your automatic build. If the config needs to be updated and stdin is redirected during a kbuild, it will already abort.
bye, Roman
Quoted 10 lines · Roman Zippel
Hi,
Quoted 6 lines · Ben Collins
That's not entirely acceptable. The reason this shows up is if an automatic build is being done, and the config files are not up-to-date, the prefered action is a build failure, not selecting defaults. The reason for my fix was that instead of filling up diskspace with a logfile of kconf's infinite loop, we just exit with an error.
Quoted 5 lines
Quoted 2 lines
Currently, this is the only way to ensure that these issues don't go unnoticed.
Then something is wrong with your automatic build. If the config needs to be updated and stdin is redirected during a kbuild, it will already abort.
And what should be directed into stdin? Nothing. There should be no input going into an automated build, exactly because it could produce incorrect results.
BTW, this is the automatic build that Debian and Ubuntu both use (in Debian's case, used for quite a number of years). So this isn't something I whipped up.
Still, the build system shouldn't have to do anything special with stdin to get the desired result. The code should also not react differently based on stdin being closed, or being pumped with nul data.
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 11 lines · Ben Collins
Quoted 3 lines
Then something is wrong with your automatic build. If the config needs to be updated and stdin is redirected during a kbuild, it will already abort.
And what should be directed into stdin? Nothing. There should be no input going into an automated build, exactly because it could produce incorrect results.
BTW, this is the automatic build that Debian and Ubuntu both use (in Debian's case, used for quite a number of years). So this isn't something I whipped up.
That just means Debian's automatic build for the kernel has been broken for years. All normal config targets require user input and no input equals default input. Only silentoldconfig will abort if input is not available.
bye, Roman
Quoted 12 lines · Roman Zippel
Hi,
Quoted 8 lines · Ben Collins
Quoted 3 lines
Then something is wrong with your automatic build. If the config needs to be updated and stdin is redirected during a kbuild, it will already abort.
And what should be directed into stdin? Nothing. There should be no input going into an automated build, exactly because it could produce incorrect results.
Quoted 7 lines
Quoted 3 lines
BTW, this is the automatic build that Debian and Ubuntu both use (in Debian's case, used for quite a number of years). So this isn't something I whipped up.
That just means Debian's automatic build for the kernel has been broken for years. All normal config targets require user input and no input equals default input. Only silentoldconfig will abort if input is not available.
I think that's broken (because I don't see where that behavior is described). IMO, based on the code, it should only go with defaults when -n -y or -m is passed. Anything else should detect when stdin is not valid and abort. If stdin is valid, and empty string is read, then that's a valid "give me the default" response.
Why is it so hard to error when stdin is closed? It's not like that will break anything.
Since silentoldconfig does this, then oldconfig should aswell. The only naming difference is that silentoldconfig is quiet, and oldconfig is not. Why should the two act any differently with a closed stdin?
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 6 lines · Ben Collins
Quoted 3 lines
That just means Debian's automatic build for the kernel has been broken for years. All normal config targets require user input and no input equals default input. Only silentoldconfig will abort if input is not available.
I think that's broken (because I don't see where that behavior is described).
I'll accept a patch to fix the documentation.
Quoted 2 lines
IMO, based on the code, it should only go with defaults when -n -y or -m is passed.
No.
Quoted 2 lines
Why is it so hard to error when stdin is closed? It's not like that will break anything.
oldconfig & co are interactive targets, so don't use them in automatic builds. If you some problem with using silentoldconfig, describe it and I'll help to solve it.
bye, Roman
Quoted 16 lines · Roman Zippel
Hi,
Quoted 6 lines · Ben Collins
Quoted 3 lines
That just means Debian's automatic build for the kernel has been broken for years. All normal config targets require user input and no input equals default input. Only silentoldconfig will abort if input is not available.
I think that's broken (because I don't see where that behavior is described).
I'll accept a patch to fix the documentation.
Quoted 2 lines
IMO, based on the code, it should only go with defaults when -n -y or -m is passed.
Quoted 8 lines
No.
Quoted 2 lines
Why is it so hard to error when stdin is closed? It's not like that will break anything.
oldconfig & co are interactive targets, so don't use them in automatic builds. If you some problem with using silentoldconfig, describe it and I'll help to solve it.
First, we need oldconfig because it allows us to look at the build log and see exactly what happened in the config stage. Silentoldconfig gives us no feedback for logs.
Now let me see if I get this right:
1) oldconfig was broken when stdin was closed. Meaning, it went into an infinite loop. This was obviously not the intended outcome.
2) silentoldconfig will, when faced with a closed stdin, abort, and notify the user.
3) Obviously since current behavior of oldconfig was broken with a closed stdin, then it was never doing what anyone wanted in this usage case. Since no one else noticed it, that means that we are the only use case for this.
4) I send a patch that fixes oldconfig with closed stdin by making it duplicate what silentoldconfig does, aborting when it needs input and stdin is closed. Since oldconfig was always broken in this usage case, this seems the obvious fix, plus it's consistent. This isn't the same as an empty string (e.g. when hitting enter), which didn't get changed, and has always meant to use the default value.
5) My patch did not break anything, nor did it change anything that was already working.
6) In response you make oldconfig work exactly opposite of silentoldconfig by using the default value for a config option when stdin is closed (basically acting like the user hit ENTER), and further break things for me in this usage case, with no purpose, and no reason for making your change the way you did. Since it was broken, you aren't helping anyone. We can't have the build system using default values. We need it to abort.
Did I get this right, or am I imagining that you are being hard headed about this?
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 3 lines · Ben Collins
First, we need oldconfig because it allows us to look at the build log and see exactly what happened in the config stage. Silentoldconfig gives us no feedback for logs.
silentoldconfig gives you exactly the same information. Both conf and oldconfig will change invisible options without telling you, so it's not exact at all.
If you can't trust a silent oldconfig, a more verbose oldconfig can't tell you anything else, if it would it's a bug.
Quoted 4 lines
3) Obviously since current behavior of oldconfig was broken with a closed stdin, then it was never doing what anyone wanted in this usage case. Since no one else noticed it, that means that we are the only use case for this.
This is enough reason to simply hijack conf and use it for your own purpose without even asking the maintainer about the intended bahaviour?
Quoted 2 lines
5) My patch did not break anything, nor did it change anything that was already working.
It _was_ working like that, you're breaking it.
Quoted 7 lines
6) In response you make oldconfig work exactly opposite of silentoldconfig by using the default value for a config option when stdin is closed (basically acting like the user hit ENTER), and further break things for me in this usage case, with no purpose, and no reason for making your change the way you did. Since it was broken, you aren't helping anyone. We can't have the build system using default values. We need it to abort.
So simply use silentoldconfig.
bye, Roman
Quoted 8 lines · Roman Zippel
Hi,
Quoted 3 lines · Ben Collins
First, we need oldconfig because it allows us to look at the build log and see exactly what happened in the config stage. Silentoldconfig gives us no feedback for logs.
Quoted 5 lines
silentoldconfig gives you exactly the same information. Both conf and oldconfig will change invisible options without telling you, so it's not exact at all.
If you can't trust a silent oldconfig, a more verbose oldconfig can't tell you anything else, if it would it's a bug.
silentoldconfig tells you a lot less, agreed? I want the verbose oldconfig, and I want it to fail on closed stdin when it needs input.
Quoted 7 lines
Quoted 4 lines
3) Obviously since current behavior of oldconfig was broken with a closed stdin, then it was never doing what anyone wanted in this usage case. Since no one else noticed it, that means that we are the only use case for this.
This is enough reason to simply hijack conf and use it for your own purpose without even asking the maintainer about the intended bahaviour?
Hijack? It was broken, correct? It has always been broken. This problem has existed for as long as I've been handling kernel builds with Debian (which seems to be about 6-7 years now). So intended behavior aside, it has never worked as intended.
Quoted 4 lines
Quoted 2 lines
5) My patch did not break anything, nor did it change anything that was already working.
It _was_ working like that, you're breaking it.
At what point did oldconfig use default values when stdin was closed? Show me the code that actually did this. Yes, it has always used default values when it was empty input, just like silentoldconfig does. But silentoldconfig aborts when stdin is closed, why should oldconfig?
Quoted 9 lines
Quoted 7 lines
6) In response you make oldconfig work exactly opposite of silentoldconfig by using the default value for a config option when stdin is closed (basically acting like the user hit ENTER), and further break things for me in this usage case, with no purpose, and no reason for making your change the way you did. Since it was broken, you aren't helping anyone. We can't have the build system using default values. We need it to abort.
So simply use silentoldconfig.
That's not the usage I want. Show me where and when oldconfig worked as you say it was intended to work. And then explain why oldconfig is intended to be inconsistent with silentoldconfig.
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 7 lines · Ben Collins
Quoted 5 lines
silentoldconfig gives you exactly the same information. Both conf and oldconfig will change invisible options without telling you, so it's not exact at all.
If you can't trust a silent oldconfig, a more verbose oldconfig can't tell you anything else, if it would it's a bug.silentoldconfig tells you a lot less, agreed?
No.
Quoted 4 lines
Hijack? It was broken, correct? It has always been broken. This problem has existed for as long as I've been handling kernel builds with Debian (which seems to be about 6-7 years now). So intended behavior aside, it has never worked as intended.
And it took you 6 years to report this problem?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
5) My patch did not break anything, nor did it change anything that was already working.
It _was_ working like that, you're breaking it.
At what point did oldconfig use default values when stdin was closed?
It broke with this patch:
Quoted 3 lines
Quoted 1 line
So simply use silentoldconfig.
That's not the usage I want.
You only want some specific output, which has zero advantage over the silentoldconfig output.
bye, Roman
Quoted 10 lines · Roman Zippel
Hi,
Quoted 6 lines · Ben Collins
Quoted 5 lines
silentoldconfig gives you exactly the same information. Both conf and oldconfig will change invisible options without telling you, so it's not exact at all.
If you can't trust a silent oldconfig, a more verbose oldconfig can't tell you anything else, if it would it's a bug.
Quoted 3 lines
Quoted 1 line
silentoldconfig tells you a lot less, agreed?
No.
So you are saying that silentoldconfig outputs no less information than oldconfig? No output compared to a full config output (yes, with some special cased invisible options, but the same output that a user would see if manually configuring).
My point is that you are making oldconfig and silentoldconfig operate differently when they encounter a closed stdin. You are making them inconsistent. And so far, you have yet to give a valid reason to do so. I've been giving very valid reasons why they should work the same, and why the behavior is correct for them to work that way.
What is the reason for silentoldconfig to fail in this way, and for oldconfig not to? I suspect you have some special usage of your own for which you depend on this functionality.
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 8 lines · Ben Collins
Quoted 3 lines
Quoted 1 line
silentoldconfig tells you a lot less, agreed?
No.
So you are saying that silentoldconfig outputs no less information than oldconfig? No output compared to a full config output (yes, with some special cased invisible options, but the same output that a user would see if manually configuring).
You're seriously telling me that you check every line of the oldconfig output in case of the problem?
If it makes you feel better, you can rerun oldconfig after the silentoldconfig, but the output is practically useless.
It would actually be a lot better if you ran a diff between the old config and the new config and add this to the build output, only the contents of the .config file is relevant to kbuild and if something went wrong, the real differences would be easily visible.
Quoted 5 lines
My point is that you are making oldconfig and silentoldconfig operate differently when they encounter a closed stdin. You are making them inconsistent. And so far, you have yet to give a valid reason to do so. I've been giving very valid reasons why they should work the same, and why the behavior is correct for them to work that way.
Even if they sound similiar they are not the same. e.g. I'm working on patches to integrate split config step, so it will do a bit more than normal config targets (but it remain a valid make target). The silentoldconfig target is an automatic target which is also used by kbuild to verify the config consistency.
The situation is very simple, we have automatic config targets (like silentoldconfig or all*config) and we have interactive config targets (like config, xconfig, oldconfig).
I'm very much interested to improve the situation of the automatic targets to help automatic builds, but just printing useless information adds no value. If you don't trust that silentoldconfig does the right thing, you can't trust oldconfig either.
bye, Roman
Quoted 6 lines · Roman Zippel
Quoted 5 lines
My point is that you are making oldconfig and silentoldconfig operate differently when they encounter a closed stdin. You are making them inconsistent. And so far, you have yet to give a valid reason to do so. I've been giving very valid reasons why they should work the same, and why the behavior is correct for them to work that way.
Quoted 12 lines
Even if they sound similiar they are not the same. e.g. I'm working on patches to integrate split config step, so it will do a bit more than normal config targets (but it remain a valid make target). The silentoldconfig target is an automatic target which is also used by kbuild to verify the config consistency.
The situation is very simple, we have automatic config targets (like silentoldconfig or all*config) and we have interactive config targets (like config, xconfig, oldconfig).
I'm very much interested to improve the situation of the automatic targets to help automatic builds, but just printing useless information adds no value. If you don't trust that silentoldconfig does the right thing, you can't trust oldconfig either.
What I don't understand is that if oldconfig is an interactive target, why make it work when interactivity is not available? Also, if silentoldconfig is an automated target, why make it abort when interactivity is not available?
Just seems backwards.
For me, silentoldconfig could work, but I prefer the verbosity of oldconfig. It's just more convenient. It's not that things are checked in minute detail, but that our builds may eventually disappear (by upgraded packages), but our build logs remain. It's the only way we have to go back and check regressions in the build process (it has saved us many times).
Signature · 3 lines
Ben Collins <[email protected]> Developer Ubuntu Linux
Hi,
Quoted 2 lines · Ben Collins
What I don't understand is that if oldconfig is an interactive target, why make it work when interactivity is not available?
It means it will accept any input and no input (by just pressing enter or ctrl-d) means the default answer.
Quoted 3 lines
Also, if
silentoldconfig is an automated target, why make it abort when interactivity is not available?
It's called during a normal kbuild and must work in any situation.
Quoted 6 lines
For me, silentoldconfig could work, but I prefer the verbosity of oldconfig. It's just more convenient. It's not that things are checked in minute detail, but that our builds may eventually disappear (by upgraded packages), but our build logs remain. It's the only way we have to go back and check regressions in the build process (it has saved us many times).
The output is unlikely to help you, you'll still have the .config file and that is a much better source to verify the configuration step.
bye, Roman