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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page