All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE
@ 2021-04-20  8:37 Chen Qi
  2021-04-30 13:34 ` Richard Purdie
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Qi @ 2021-04-20  8:37 UTC (permalink / raw)
  To: openembedded-core

oe-pkgdata-util sometimes outputs a large amount of data. When used
with pipe, it's likely to get the following error.

  BrokenPipeError: [Errno 32] Broken pipe

The problem could be reproduced by running `oe-pkgdata-util list-pkg | less'.
Type 'q' after running the above command, and we get the error.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/oe-pkgdata-util | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 75dd23efa3..4aeb28879d 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -17,6 +17,7 @@ import re
 import argparse
 import logging
 from collections import defaultdict, OrderedDict
+from signal import signal, SIGPIPE, SIG_DFL
 
 scripts_path = os.path.dirname(os.path.realpath(__file__))
 lib_path = scripts_path + '/lib'
@@ -615,6 +616,10 @@ def main():
         logger.error('Unable to find pkgdata directory %s' % args.pkgdata_dir)
         sys.exit(1)
 
+    # It's possible that this program will output large contents, and when used with a pipe in command line,
+    # we will get a 'BrokenPipeError: [Errno 32] Broken pipe'. Ignore the SIGPIPE to avoid such error.
+    signal(SIGPIPE, SIG_DFL)
+
     ret = args.func(args)
 
     return ret
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE
  2021-04-20  8:37 [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE Chen Qi
@ 2021-04-30 13:34 ` Richard Purdie
  2021-05-06  2:14   ` Chen Qi
  2021-05-06  4:03   ` Chen Qi
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Purdie @ 2021-04-30 13:34 UTC (permalink / raw)
  To: Chen Qi, openembedded-core

On Tue, 2021-04-20 at 16:37 +0800, Chen Qi wrote:
> oe-pkgdata-util sometimes outputs a large amount of data. When used
> with pipe, it's likely to get the following error.
> 
>   BrokenPipeError: [Errno 32] Broken pipe
> 
> The problem could be reproduced by running `oe-pkgdata-util list-pkg | less'.
> Type 'q' after running the above command, and we get the error.
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  scripts/oe-pkgdata-util | 5 +++++
>  1 file changed, 5 insertions(+)

This is far from clearcut. 

https://mail.python.org/pipermail/python-dev/2018-June/154191.html

Not quite sure what to do about this as there are pros/cons...

Cheers,

Richard

> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
> index 75dd23efa3..4aeb28879d 100755
> --- a/scripts/oe-pkgdata-util
> +++ b/scripts/oe-pkgdata-util
> @@ -17,6 +17,7 @@ import re
>  import argparse
>  import logging
>  from collections import defaultdict, OrderedDict
> +from signal import signal, SIGPIPE, SIG_DFL
>  
> 
> 
> 
>  scripts_path = os.path.dirname(os.path.realpath(__file__))
>  lib_path = scripts_path + '/lib'
> @@ -615,6 +616,10 @@ def main():
>          logger.error('Unable to find pkgdata directory %s' % args.pkgdata_dir)
>          sys.exit(1)
>  
> 
> 
> 
> +    # It's possible that this program will output large contents, and when used with a pipe in command line,
> +    # we will get a 'BrokenPipeError: [Errno 32] Broken pipe'. Ignore the SIGPIPE to avoid such error.
> +    signal(SIGPIPE, SIG_DFL)
> +
>      ret = args.func(args)
>  
> 
> 
> 
>      return ret
> 
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE
  2021-04-30 13:34 ` Richard Purdie
@ 2021-05-06  2:14   ` Chen Qi
  2021-05-06  4:03   ` Chen Qi
  1 sibling, 0 replies; 5+ messages in thread
From: Chen Qi @ 2021-05-06  2:14 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

On 04/30/2021 09:34 PM, Richard Purdie wrote:
> On Tue, 2021-04-20 at 16:37 +0800, Chen Qi wrote:
>> oe-pkgdata-util sometimes outputs a large amount of data. When used
>> with pipe, it's likely to get the following error.
>>
>>    BrokenPipeError: [Errno 32] Broken pipe
>>
>> The problem could be reproduced by running `oe-pkgdata-util list-pkg | less'.
>> Type 'q' after running the above command, and we get the error.
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   scripts/oe-pkgdata-util | 5 +++++
>>   1 file changed, 5 insertions(+)
> This is far from clearcut.
>
> https://mail.python.org/pipermail/python-dev/2018-June/154191.html
>
> Not quite sure what to do about this as there are pros/cons...
>
> Cheers,
>
> Richard

Thanks Richard. I've read the material above and grabbed more knowledge 
on this topic.

At first, I also wanted to use the 'try ... except' clause to handle the 
output of oe-pkgdata-utils. But there are multiple places for the 
output, so I figured it's ugly and not necessary.

People mentioned situations where setting SIG_DFL for SIGPIPE is 
harmful. That's true. But in respect to this oe-pkgutils-data program, 
when setting SIG_DFL for SIGPIPE, what would be the actual problem in 
practice?

So I think https://github.com/python/cpython/pull/6773 is meaningful, 
but it does not apply to all programs.

Anyway, if you think using the 'try...except' clause is better, I could 
do it and send out V2. But I'm still wondering what extra benefit it 
could bring us.

Best Regards,
Chen Qi

>> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
>> index 75dd23efa3..4aeb28879d 100755
>> --- a/scripts/oe-pkgdata-util
>> +++ b/scripts/oe-pkgdata-util
>> @@ -17,6 +17,7 @@ import re
>>   import argparse
>>   import logging
>>   from collections import defaultdict, OrderedDict
>> +from signal import signal, SIGPIPE, SIG_DFL
>>   
>>
>>
>>
>>   scripts_path = os.path.dirname(os.path.realpath(__file__))
>>   lib_path = scripts_path + '/lib'
>> @@ -615,6 +616,10 @@ def main():
>>           logger.error('Unable to find pkgdata directory %s' % args.pkgdata_dir)
>>           sys.exit(1)
>>   
>>
>>
>>
>> +    # It's possible that this program will output large contents, and when used with a pipe in command line,
>> +    # we will get a 'BrokenPipeError: [Errno 32] Broken pipe'. Ignore the SIGPIPE to avoid such error.
>> +    signal(SIGPIPE, SIG_DFL)
>> +
>>       ret = args.func(args)
>>   
>>
>>
>>
>>       return ret
>> 
>>
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE
  2021-04-30 13:34 ` Richard Purdie
  2021-05-06  2:14   ` Chen Qi
@ 2021-05-06  4:03   ` Chen Qi
  1 sibling, 0 replies; 5+ messages in thread
From: Chen Qi @ 2021-05-06  4:03 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

On 04/30/2021 09:34 PM, Richard Purdie wrote:
> On Tue, 2021-04-20 at 16:37 +0800, Chen Qi wrote:
>> oe-pkgdata-util sometimes outputs a large amount of data. When used
>> with pipe, it's likely to get the following error.
>>
>>    BrokenPipeError: [Errno 32] Broken pipe
>>
>> The problem could be reproduced by running `oe-pkgdata-util list-pkg | less'.
>> Type 'q' after running the above command, and we get the error.
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   scripts/oe-pkgdata-util | 5 +++++
>>   1 file changed, 5 insertions(+)
> This is far from clearcut.
>
> https://mail.python.org/pipermail/python-dev/2018-June/154191.html
>
> Not quite sure what to do about this as there are pros/cons...
>
> Cheers,
>
> Richard

Thanks Richard. I've read the material above and grabbed more knowledge 
on this topic.

At first, I also wanted to use the 'try ... except' clause to handle the 
output of oe-pkgdata-utils. But there are multiple places for the 
output, so I figured it's ugly and not necessary.

People mentioned situations where setting SIG_DFL for SIGPIPE is 
harmful. That's true. But in respect to this oe-pkgutils-data program, 
when setting SIG_DFL for SIGPIPE, what would be the actual problem in 
practice?

So I think https://github.com/python/cpython/pull/6773 is meaningful, 
but it does not apply to all programs.

Anyway, if you think using the 'try...except' clause is better, I could 
do it and send out V2. But I'm still wondering what extra benefit it 
could bring us.

Best Regards,
Chen Qi

>> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
>> index 75dd23efa3..4aeb28879d 100755
>> --- a/scripts/oe-pkgdata-util
>> +++ b/scripts/oe-pkgdata-util
>> @@ -17,6 +17,7 @@ import re
>>   import argparse
>>   import logging
>>   from collections import defaultdict, OrderedDict
>> +from signal import signal, SIGPIPE, SIG_DFL
>>   
>>
>>
>>
>>   scripts_path = os.path.dirname(os.path.realpath(__file__))
>>   lib_path = scripts_path + '/lib'
>> @@ -615,6 +616,10 @@ def main():
>>           logger.error('Unable to find pkgdata directory %s' % args.pkgdata_dir)
>>           sys.exit(1)
>>   
>>
>>
>>
>> +    # It's possible that this program will output large contents, and when used with a pipe in command line,
>> +    # we will get a 'BrokenPipeError: [Errno 32] Broken pipe'. Ignore the SIGPIPE to avoid such error.
>> +    signal(SIGPIPE, SIG_DFL)
>> +
>>       ret = args.func(args)
>>   
>>
>>
>>
>>       return ret
>> 
>>
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE
       [not found] <1677842B2B4EE882.30395@lists.openembedded.org>
@ 2021-04-27  2:53 ` Chen Qi
  0 siblings, 0 replies; 5+ messages in thread
From: Chen Qi @ 2021-04-27  2:53 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

ping

On 04/20/2021 04:37 PM, Chen Qi wrote:
> oe-pkgdata-util sometimes outputs a large amount of data. When used
> with pipe, it's likely to get the following error.
>
>    BrokenPipeError: [Errno 32] Broken pipe
>
> The problem could be reproduced by running `oe-pkgdata-util list-pkg | less'.
> Type 'q' after running the above command, and we get the error.
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   scripts/oe-pkgdata-util | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
> index 75dd23efa3..4aeb28879d 100755
> --- a/scripts/oe-pkgdata-util
> +++ b/scripts/oe-pkgdata-util
> @@ -17,6 +17,7 @@ import re
>   import argparse
>   import logging
>   from collections import defaultdict, OrderedDict
> +from signal import signal, SIGPIPE, SIG_DFL
>   
>   scripts_path = os.path.dirname(os.path.realpath(__file__))
>   lib_path = scripts_path + '/lib'
> @@ -615,6 +616,10 @@ def main():
>           logger.error('Unable to find pkgdata directory %s' % args.pkgdata_dir)
>           sys.exit(1)
>   
> +    # It's possible that this program will output large contents, and when used with a pipe in command line,
> +    # we will get a 'BrokenPipeError: [Errno 32] Broken pipe'. Ignore the SIGPIPE to avoid such error.
> +    signal(SIGPIPE, SIG_DFL)
> +
>       ret = args.func(args)
>   
>       return ret
>
>
> 
>


[-- Attachment #2: Type: text/html, Size: 1924 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-06  3:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  8:37 [OE-core][PATCH] oe-pkgdata-util: ignore SIGPIPE Chen Qi
2021-04-30 13:34 ` Richard Purdie
2021-05-06  2:14   ` Chen Qi
2021-05-06  4:03   ` Chen Qi
     [not found] <1677842B2B4EE882.30395@lists.openembedded.org>
2021-04-27  2:53 ` Chen Qi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.