Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-10

Use /dev/null for stdout

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Amir
to Martin Grajcar

In Linux, I redirect stdin from a file (and/or stdout to a file) by putting "< input.txt"  ("> output.txt", respectively) in Run Parameters -> Command Line parameters.

I believe that should work for MacOS...

Martin Grajcar wrote 5 lines
My process may get started with or without console. In the latter case, any write leads to "Disk full" on MacOS. As I can't eliminate all writes, I'd need to open both stdout and stderr as /dev/null.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20181023/804375b3/attachment.html>

Reply by email

Martin Frb
to Martin Grajcar: My process may get started with or without console. In the latter case, any write leads…
Martin Grajcar wrote
My process may get started with or without console. In the latter case, any write leads to "Disk full" on MacOS. As I can't eliminate all writes, I'd need to open both stdout and stderr as /dev/null.

Have a look at logger frameworks.

LazLogger is included: http://wiki.lazarus.freepascal.org/LazLogger Use "debugln" instead of "writeln". debugln will test if stdout is open or not.

There are still cases where stdout can return a "disk full", those are (in the latest version) caught and ignored.

Reply by email

leledumbo
to Martin Grajcar: My process may get started with or without console. In the latter case, any write leads…
I'd need to open both stdout and stderr as /dev/null.

Both are represented as System.Text (or ObjPas.TextFile) named System.Output and System.StdErr respectively (There are also System.StdOut and System.ErrOutput as their alias, but it looks like they're not proper alias but rather different instances pointing to the same file), you can System.Close, Re-System.Assign to '/dev/null' at runtime (start of your program, maybe?) then Re-Rewrite them. From that point onwards, every call to Write[Ln](...) will write to /dev/null.

Reply by email