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













16















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


  1. Is this normal behavior of strings? If so, why?

  2. Where is the data written after there's no more space left?









share|improve this question









New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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 the strace 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















16















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


  1. Is this normal behavior of strings? If so, why?

  2. Where is the data written after there's no more space left?









share|improve this question









New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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 the strace 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













16












16








16


2






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


  1. Is this normal behavior of strings? If so, why?

  2. Where is the data written after there's no more space left?









share|improve this question









New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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


  1. Is this normal behavior of strings? If so, why?

  2. Where is the data written after there's no more space left?






linux shell string






share|improve this question









New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 21 hours ago









Olorin

3,6781621




3,6781621






New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









user174174user174174

864




864




New contributor




user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user174174 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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 the strace 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





    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 the strace 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










1 Answer
1






active

oldest

votes


















36














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.









draft saved

draft discarded


















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









36














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 in strings.

    – kasperd
    14 hours ago























  • 9





    Nice analysis. I'd say that should be considered a bug in strings.

    – kasperd
    14 hours ago









sharex(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)
...






share|improve this answer












share|improve this answer



share|improve this answer










answered 21 hours ago









OlorinOlorin

3,6781621




3,6781621







  • 9





    Nice analysis. I'd say that should be considered a bug in strings.

    – kasperd
    14 hours ago












  • 9





    Nice analysis. I'd say that should be considered a bug in strings.

    – 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










user174174 is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme