Discussion:
[Lazarus] Use /dev/null for stdout
Martin Grajcar via Lazarus
2018-10-23 21:42:08 UTC
Permalink
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.
Amir via Lazarus
2018-10-24 03:46:02 UTC
Permalink
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...
Post by Martin Grajcar via Lazarus
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.
Martin Frb via Lazarus
2018-10-24 11:07:22 UTC
Permalink
Post by Martin Grajcar via Lazarus
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.
--
leledumbo via Lazarus
2018-10-26 04:40:25 UTC
Permalink
Post by Martin Grajcar via Lazarus
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.



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--

Loading...