Why won't the strings command stop?Why is return is ignored during output in bash?Excessively high memory usage reported (3 GB) after reboot&> redirection not working correctlyCentOS can't use new extented space on system discWhy does 'nohup command >& /dev/null' seem to “work” in some shells?Is it bad to have a low entropy in /dev/random?bash - Separate “table” values into strings in arrayWhy stderr is required?0 bytes of swap space available, recommended 10gbDisconnected block device remains in /dev/, sync commands unkillable
School performs periodic password audits. Is my password compromised?
Canadian citizen, on US no-fly list. What can I do in order to be allowed on flights which go through US airspace?
How to get the first element while continue streaming?
How do you say “my friend is throwing a party, do you wanna come?” in german
3.5% Interest Student Loan or use all of my savings on Tuition?
Why won't the strings command stop?
I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?
is 'sed' thread safe
function only contains jump discontinuity but is not piecewise continuous
Sometimes a banana is just a banana
Quitting employee has privileged access to critical information
Formatting a table to look nice
Specific Chinese carabiner QA?
Is every open circuit a capacitor?
Why are special aircraft used for the carriers in the United States Navy?
How do we objectively assess if a dialogue sounds unnatural or cringy?
Giving a talk in my old university, how prominently should I tell students my salary?
Can the Shape Water Cantrip be used to manipulate blood?
Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?
How to kill a localhost:8080
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
How can I be pwned if I'm not registered on the compromised site?
Can a Trickery Domain cleric cast a spell through the Invoke Duplicity clone while inside a Forcecage?
It doesn't matter the side you see it
Why won't the strings command stop?
Why is return is ignored during output in bash?Excessively high memory usage reported (3 GB) after reboot&> redirection not working correctlyCentOS can't use new extented space on system discWhy does 'nohup command >& /dev/null' seem to “work” in some shells?Is it bad to have a low entropy in /dev/random?bash - Separate “table” values into strings in arrayWhy stderr is required?0 bytes of swap space available, recommended 10gbDisconnected block device remains in /dev/, sync commands unkillable
The strings
command behaves weirdly, apparently it doesn't stop writing to a file even if drive run out of space. Or perhaps I'm missing something?
I run the following:
# strings /dev/urandom > random.txt
this was keep running and didn't stop even after filling the disk (a regular usb flash).
then to be quicker I created a ramdisk and tried again the same command. it also didn't stop.
I understand that urandom
isn't a regular file and also strings
's output is redirected, however in both cases above, the cat
command reported the error when there was no more space.
# cat /dev/urandom > random.txt
cat: write error: No space left on device
- Is this normal behavior of strings? If so, why?
- Where is the data written after there's no more space left?
linux shell string
New contributor
|
show 3 more comments
The strings
command behaves weirdly, apparently it doesn't stop writing to a file even if drive run out of space. Or perhaps I'm missing something?
I run the following:
# strings /dev/urandom > random.txt
this was keep running and didn't stop even after filling the disk (a regular usb flash).
then to be quicker I created a ramdisk and tried again the same command. it also didn't stop.
I understand that urandom
isn't a regular file and also strings
's output is redirected, however in both cases above, the cat
command reported the error when there was no more space.
# cat /dev/urandom > random.txt
cat: write error: No space left on device
- Is this normal behavior of strings? If so, why?
- Where is the data written after there's no more space left?
linux shell string
New contributor
1
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
1
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
2
@Kusalananda: you can test this easily withstrace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
2
@mosvy OpenBSD uses that samestrings
implementation from GNU binutils. I was referring to thestrace
command.
– Kusalananda
9 hours ago
2
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago
|
show 3 more comments
The strings
command behaves weirdly, apparently it doesn't stop writing to a file even if drive run out of space. Or perhaps I'm missing something?
I run the following:
# strings /dev/urandom > random.txt
this was keep running and didn't stop even after filling the disk (a regular usb flash).
then to be quicker I created a ramdisk and tried again the same command. it also didn't stop.
I understand that urandom
isn't a regular file and also strings
's output is redirected, however in both cases above, the cat
command reported the error when there was no more space.
# cat /dev/urandom > random.txt
cat: write error: No space left on device
- Is this normal behavior of strings? If so, why?
- Where is the data written after there's no more space left?
linux shell string
New contributor
The strings
command behaves weirdly, apparently it doesn't stop writing to a file even if drive run out of space. Or perhaps I'm missing something?
I run the following:
# strings /dev/urandom > random.txt
this was keep running and didn't stop even after filling the disk (a regular usb flash).
then to be quicker I created a ramdisk and tried again the same command. it also didn't stop.
I understand that urandom
isn't a regular file and also strings
's output is redirected, however in both cases above, the cat
command reported the error when there was no more space.
# cat /dev/urandom > random.txt
cat: write error: No space left on device
- Is this normal behavior of strings? If so, why?
- Where is the data written after there's no more space left?
linux shell string
linux shell string
New contributor
New contributor
edited 21 hours ago
Olorin
3,6781621
3,6781621
New contributor
asked yesterday
user174174user174174
864
864
New contributor
New contributor
1
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
1
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
2
@Kusalananda: you can test this easily withstrace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
2
@mosvy OpenBSD uses that samestrings
implementation from GNU binutils. I was referring to thestrace
command.
– Kusalananda
9 hours ago
2
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago
|
show 3 more comments
1
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
1
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
2
@Kusalananda: you can test this easily withstrace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
2
@mosvy OpenBSD uses that samestrings
implementation from GNU binutils. I was referring to thestrace
command.
– Kusalananda
9 hours ago
2
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago
1
1
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
1
1
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
2
2
@Kusalananda: you can test this easily with
strace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
@Kusalananda: you can test this easily with
strace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
2
2
@mosvy OpenBSD uses that same
strings
implementation from GNU binutils. I was referring to the strace
command.– Kusalananda
9 hours ago
@mosvy OpenBSD uses that same
strings
implementation from GNU binutils. I was referring to the strace
command.– Kusalananda
9 hours ago
2
2
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago
|
show 3 more comments
1 Answer
1
active
oldest
votes
If GNU cat
can't write out what it read, it will exit with an error:
/* Write this block out. */
/* The following is ok, since we know that 0 < n_read. */
size_t n = n_read;
if (full_write (STDOUT_FILENO, buf, n) != n)
die (EXIT_FAILURE, errno, _("write error"));
GNU strings
, on the other hand, doesn't care whether it managed to write successfully:
while (1)
c = get_char (stream, &address, &magiccount, &magic);
if (c == EOF)
break;
if (! STRING_ISGRAPHIC (c))
unget_part_char (c, &address, &magiccount, &magic);
break;
putchar (c);
So all those writes fail, but strings
continues merrily along, until it reaches end of input, which will be never.
$ strace -e write strings /dev/urandom > foo/bar
write(1, "7[\Zn]juKwnl [1nTc9gn0&}x(xn/y^7"..., 4096) = 4096
write(1, "nXaki%ndHB0n?5:Qn6bX-np!E[n'&=7n"..., 4096) = 4096
write(1, "%M6sn=4C.%n&7)nnQ_%JncT+";nK*<%n"..., 4096) = 4096
write(1, "&d<nj~g0nm]=ona=^0n%s]2WnM7C%nUK"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "~nd3qQn^^u1#na#5\n^=t"bn*91_n ]o"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "Ln6QO1xna,yEnk>",@ZnyM.urn~ztFnr"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "n61]Rnyg9CnfLVun<Ez:n.tV-cnw_'>e"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nCj)anT]X:uAn_KH"BnRfQ4Gn3retn&s"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "jnk7@%n9E?^NnJ#8Vn*]i,nXDxh?nr_1"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "iatInQ)ZwnnV0JnE3-W n@0-N2vnK{15"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nZ~*gn)FQnnUY:GndRbNnn..FnvF
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
user174174 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504616%2fwhy-wont-the-strings-command-stop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If GNU cat
can't write out what it read, it will exit with an error:
/* Write this block out. */
/* The following is ok, since we know that 0 < n_read. */
size_t n = n_read;
if (full_write (STDOUT_FILENO, buf, n) != n)
die (EXIT_FAILURE, errno, _("write error"));
GNU strings
, on the other hand, doesn't care whether it managed to write successfully:
while (1)
c = get_char (stream, &address, &magiccount, &magic);
if (c == EOF)
break;
if (! STRING_ISGRAPHIC (c))
unget_part_char (c, &address, &magiccount, &magic);
break;
putchar (c);
So all those writes fail, but strings
continues merrily along, until it reaches end of input, which will be never.
$ strace -e write strings /dev/urandom > foo/bar
write(1, "7[\Zn]juKwnl [1nTc9gn0&x(xn/y^7"..., 4096) = 4096
write(1, "nXaki%ndHB0n?5:Qn6bX-np!E[n'&=7n"..., 4096) = 4096
write(1, "%M6sn=4C.%n&7)nnQ_%JncT+";nK*<%n"..., 4096) = 4096
write(1, "&d<nj~g0nm]=ona=^0n%s]2WnM7C%nUK"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "~nd3qQn^^u1#na#5\n^=t"bn*91_n ]o"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "Ln6QO1xna,yEnk>",@ZnyM.urn~ztFnr"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "n61]Rnyg9CnfLVun<Ez:n.tV-cnw_'>e"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nCj)anT]X:uAn_KH"BnRfQ4Gn3retn&s"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "jnk7@%n9E?^NnJ#8Vn*]i,nXDxh?nr_1"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "iatInQ)ZwnnV0JnE3-W n@0-N2vnK{15"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nZ~*gn)FQnnUY:GndRbNnn..FnvFimprove this answer
9
Nice analysis. I'd say that should be considered a bug instrings
.
– kasperd
14 hours ago
add a comment x(xn/y^7"..., 4096) = 4096
write(1, "nXaki%ndHB0n?5:Qn6bX-np!E[n'&=7n"..., 4096) = 4096
write(1, "%M6sn=4C.%n&7)nnQ_%JncT+";nK*<%n"..., 4096) = 4096
write(1, "&d<nj~g0nm]=ona=^0n%s]2WnM7C%nUK"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "~nd3qQn^^u1#na#5\n^=t"bn*91_n ]o"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "Ln6QO1xna,yEnk>",@ZnyM.urn~ztFnr"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "n61]Rnyg9CnfLVun<Ez:n.tV-cnw_'>e"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nCj)anT]X:uAn_KH"BnRfQ4Gn3retn&s"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "jnk7@%n9E?^NnJ#8Vn*]i,nXDxh?nr_1"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "iatInQ)ZwnnV0JnE3-W n@0-N2vnK{15"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nZ~*gn)FQnnUY:GndRbNnn..FnvFimprove this answer
9
Nice analysis. I'd say that should be considered a bug instrings
.
– kasperd
14 hours ago
add a comment x(xn/y^7"..., 4096) = 4096
write(1, "nXaki%ndHB0n?5:Qn6bX-np!E[n'&=7n"..., 4096) = 4096
write(1, "%M6sn=4C.%n&7)nnQ_%JncT+";nK*<%n"..., 4096) = 4096
write(1, "&d<nj~g0nm]=ona=^0n%s]2WnM7C%nUK"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "~nd3qQn^^u1#na#5\n^=t"bn*91_n ]o"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "Ln6QO1xna,yEnk>",@ZnyM.urn~ztFnr"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "n61]Rnyg9CnfLVun<Ez:n.tV-cnw_'>e"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nCj)anT]X:uAn_KH"BnRfQ4Gn3retn&s"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "jnk7@%n9E?^NnJ#8Vn*]i,nXDxh?nr_1"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "iatInQ)ZwnnV0JnE3-W n@0-N2vnK{15"..., 4096) = -1 ENOSPC (No space left on device)
write(1, "nZ~*gn)FQnnUY:GndRbNnn..FnvF,n+"..., 4096) = -1 ENOSPC (No space left on device)
...
answered 21 hours ago
OlorinOlorin
3,6781621
3,6781621
9
Nice analysis. I'd say that should be considered a bug instrings
.
– kasperd
14 hours ago
add a comment |
9
Nice analysis. I'd say that should be considered a bug instrings
.
– kasperd
14 hours ago
9
9
Nice analysis. I'd say that should be considered a bug in
strings
.– kasperd
14 hours ago
Nice analysis. I'd say that should be considered a bug in
strings
.– kasperd
14 hours ago
add a comment |
user174174 is a new contributor. Be nice, and check out our Code of Conduct.
user174174 is a new contributor. Be nice, and check out our Code of Conduct.
user174174 is a new contributor. Be nice, and check out our Code of Conduct.
user174174 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504616%2fwhy-wont-the-strings-command-stop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What was the indication that your first command had actually filled up the disk?
– Kusalananda
21 hours ago
1
@Kusalananda It was reported by df. I was monitoring it from another virtual terminal using watch df -h
– user174174
21 hours ago
2
@Kusalananda: you can test this easily with
strace strings /dev/urandom > /dev/full
– Peter Cordes
19 hours ago
2
@mosvy OpenBSD uses that same
strings
implementation from GNU binutils. I was referring to thestrace
command.– Kusalananda
9 hours ago
2
@Kusalananda OK, because the "BSD toolchain" replacement of strings(1) doesn't check for the return value of putchar() either
– mosvy
9 hours ago