[Lazarus] Use /dev/null for stdout

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Use /dev/null for stdout

Free Pascal - Lazarus mailing list
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.


--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Use /dev/null for stdout

Free Pascal - Lazarus mailing list

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

On 10/23/18 2:42 PM, Martin Grajcar via Lazarus 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.



--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Use /dev/null for stdout

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 23/10/2018 23:42, Martin Grajcar via Lazarus 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.
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Use /dev/null for stdout

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
> 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/
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus