Tiny Core Extensions > TCE Bugs

[Solved] in havoc terminal emulator: yes causes broken pipes

<< < (3/8) > >>

GNUser:

--- Quote from: Juanito on October 27, 2023, 10:24:16 AM ---Why not file a bug report against weston or havoc?

--- End quote ---
Good idea. Will do.


--- Quote from: Rich on October 27, 2023, 10:37:13 AM ---What if you do it like this:

--- Code: ---echo -e  "password\npassword" | bcrypt somefile
--- End code ---

--- End quote ---
Wow. Yes, that works and is much more elegant. Thank you!

jazzbiker:

--- Quote from: GNUser on October 27, 2023, 10:17:52 AM ---
Darn. In that case, I created this trivial wrapper script for yes, which does away with the errors when using tce-load:

--- Code: ---#!/bin/sh
exec /usr/bin/yes "$@" 2>/dev/null
--- End code ---
But that doesn't solve scripts where yes is needed multiple times in same pipeline. Even with the wrapper script, something like this:

--- Code: ---yes "password" | bcrypt somefile
--- End code ---
seems to enter an endless loop, driving CPU usage way up. Workaround for this situation is this kludge:

--- Code: ---i=1
while true; do
echo "password"
[ $i -eq 2 ] && break
i=$(( $i + 1 ))
done | bcrypt somefile

--- End code ---
If I figure out how to properly fix the bug in the terminal emulators, I'll post it here.

--- End quote ---

Maybe trap instruction in the wrapper will help? Something like

--- Code: ---#!/bin/sh
trap 'exit 0' SIGPIPE
exec /usr/bin/yes "$@" 2>/dev/null

--- End code ---

Rich:
Hi GNUser
You are welcome. Thanks for confirming it worked.

If you feel like satisfying my curiosity, what happens if you do this:

--- Code: ---echo -e  "password\npassword\npassword" | bcrypt somefile
--- End code ---
I expect another  Broken pipe  message, but reality may differ from my expectations.

GNUser:
Hi jazzbiker. No luck with the trap. But it's not surprising because with the exec statement, the script no longer exists in RAM when /usr/bin/yes executes.

So I also tried your suggestion without exec, like this:

--- Code: ---#!/bin/sh
trap 'exit 0' SIGPIPE
/usr/bin/yes "$@" 2>/dev/null

--- End code ---
But no luck with that, either.

Hi Rich. The superfluous passwords do not cause a Broken pipe message, surprisingly:

--- Code: ---$ echo -e "tinycore\ntinycore\ntinycore\ntinycore\ntinycore\ntinycore" | bcrypt test.txt
Encryption key:
Again:
$

--- End code ---
So the problem does not seem to be due to  yes  not knowing when to stop.

I'm happy with the wrapper script to fix the cosmetic issue when using  tce-load  and Rich's workaround for bcrypt. Thank you all :)

jazzbiker:
Hi GNUser,

I see that the problem is solved, so maybe if it is still interesting for You and You have a spare minute You may try not use the wrapper for yes but try declaration of the SIGPIPE handler inside tce-load script.

Edit: maybe better to set ignore for the SIGPIPE:

--- Code: ---trap '' SIGPIPE
--- End code ---


--- Quote from: GNUser on October 27, 2023, 03:39:23 PM ---Hi Rich. The superfluous passwords do not cause a Broken pipe message, surprisingly:

--- Code: ---$ echo -e "tinycore\ntinycore\ntinycore\ntinycore\ntinycore\ntinycore" | bcrypt test.txt
Encryption key:
Again:
$

--- End code ---

--- End quote ---
Probably the pipe is buffered and the string is small enough to be placed in the buffer as a whole.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version