Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27805 > unrolled thread
| Started by | www <xsli2@yahoo.com> |
|---|---|
| First post | 2014-03-21 13:13 -0700 |
| Last post | 2014-03-22 11:24 +0000 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
can Java program abolish file descriptor 1 so no any programs can print to the monitor? www <xsli2@yahoo.com> - 2014-03-21 13:13 -0700
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-21 17:14 -0400
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Roedy Green <see_website@mindprod.com.invalid> - 2014-03-21 15:54 -0700
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Joerg Meier <joergmmeier@arcor.de> - 2014-03-21 23:59 +0100
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Roedy Green <see_website@mindprod.com.invalid> - 2014-03-22 02:32 -0700
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Joerg Meier <joergmmeier@arcor.de> - 2014-03-22 11:33 +0100
Re: can Java program abolish file descriptor 1 so no any programs can print to the monitor? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-03-22 11:24 +0000
| From | www <xsli2@yahoo.com> |
|---|---|
| Date | 2014-03-21 13:13 -0700 |
| Subject | can Java program abolish file descriptor 1 so no any programs can print to the monitor? |
| Message-ID | <1df2cef3-b358-465c-9d56-1c8739a17051@googlegroups.com> |
a program currently running is printing something to the terminal. I am wondering if I can use some Java to intercept those printed message so that those message do not show up on the terminal. That program is not started by the Java program. I am working on Linux. My understanding of file system is that there is a filedescriptor 0 -- the keyboard input are saved in that file and other programs take it from there; there is another filesdescriptor 1 -- the messages printed by computer programs are put into that file first, then its content is dumped to the monitor. So I think if I can let Java code erase my computer filedescriptor 1, then nothing will be printed to the monitor. file descriptor 2 is another file and is for the stderr. I think this is an interesting exercise for me.
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2014-03-21 17:14 -0400 |
| Message-ID | <lgia4g$v69$1@dont-email.me> |
| In reply to | #27805 |
On 3/21/2014 4:13 PM, www wrote:
> a program currently running is printing something to the terminal. I am wondering if I can use some Java to intercept those printed message so that those message do not show up on the terminal.
>
> That program is not started by the Java program. I am working on Linux.
>
> My understanding of file system is that there is a filedescriptor 0 -- the keyboard input are saved in that file and other programs take it from there; there is another filesdescriptor 1 -- the messages printed by computer programs are put into that file first, then its content is dumped to the monitor. So I think if I can let Java code erase my computer filedescriptor 1, then nothing will be printed to the monitor. file descriptor 2 is another file and is for the stderr.
Every Unix process has its own set of file descriptors.[*]
There is no system-wide "file descriptor 1" that program A could
somehow erase or make unavailable to program B. (If there were
such a system-wide thing and A deleted it, it would also become
unavailable to programs C,D,E,...,Z,AA,AB,...)
Also, your notions about buffering input and output in files
while it's in transit between programs and devices are a little
wide of the mark. A "file descriptor" need not refer to a disk
file; it can refer to anything that satisfies Unix' abstract
notion of "file:" disk file, tty, socket, pipe, ... There is
no on-disk file whose deletion would cause the program's output
to go somewhere else than it's already going. (Well, I suppose
you could suppress the program's output by deleting so many
crucial system files that the whole O/S came crashing down in
flaming ruins -- but you might not want to do that...)
[*] Sometimes two or more processes can share a single file
descriptor. This happens most often when a parent process uses
a process-creating system call like fork(), and the child process
inherits all the parent's open descriptors. There are also some
fairly "advanced" techniques that allow one process to create a
file descriptor and share it with another already-running process.
But in the ordinary scheme of things, two "unrelated" processes --
like your printing program and your Java program -- have no file
descriptors in common.
> I think this is an interesting exercise for me.
I think two things: First, that you should learn about the
"/dev/null" pseudo-device and how to do I/O redirection, and
second, that your question will get better answers in
comp.unix.programmer than here.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-03-21 15:54 -0700 |
| Message-ID | <jmgpi959340ht4jllg6fvu5bkh9emtmj2d@4ax.com> |
| In reply to | #27805 |
On Fri, 21 Mar 2014 13:13:36 -0700 (PDT), www <xsli2@yahoo.com> wrote, quoted or indirectly quoted someone who said : >a program currently running is printing something to the terminal. I am won= >dering if I can use some Java to intercept those printed message so that th= >ose message do not show up on the terminal. read up on java.lang.System.setOut -- Roedy Green Canadian Mind Products http://mindprod.com "Incorrect documentation is often worse than no documentation." ~ Bertrand Meyer (born: 1950 age: 63), creator of design by contract and the Eiffel language.
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-21 23:59 +0100 |
| Message-ID | <4zovuikxvhos.1xda7e9v07azx$.dlg@40tude.net> |
| In reply to | #27808 |
On Fri, 21 Mar 2014 15:54:02 -0700, Roedy Green wrote: > On Fri, 21 Mar 2014 13:13:36 -0700 (PDT), www <xsli2@yahoo.com> wrote, > quoted or indirectly quoted someone who said : >>a program currently running is printing something to the terminal. I am won= >>dering if I can use some Java to intercept those printed message so that th= >>ose message do not show up on the terminal. > read up on java.lang.System.setOut That's really got nothing at all to do with what he's asking as far as I understood. Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-03-22 02:32 -0700 |
| Message-ID | <14mqi9hmt1lvrc7vp46qrg4dqpt85he1jm@4ax.com> |
| In reply to | #27809 |
On Fri, 21 Mar 2014 23:59:57 +0100, Joerg Meier <joergmmeier@arcor.de> wrote, quoted or indirectly quoted someone who said : >That's really got nothing at all to do with what he's asking as far as I >understood. It is not what he asked for, but I think it is what he needs. -- Roedy Green Canadian Mind Products http://mindprod.com "Incorrect documentation is often worse than no documentation." ~ Bertrand Meyer (born: 1950 age: 63), creator of design by contract and the Eiffel language.
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-22 11:33 +0100 |
| Message-ID | <19i32nhpyhhb7$.1ae9gqicwjbl0$.dlg@40tude.net> |
| In reply to | #27810 |
On Sat, 22 Mar 2014 02:32:03 -0700, Roedy Green wrote: > On Fri, 21 Mar 2014 23:59:57 +0100, Joerg Meier <joergmmeier@arcor.de> > wrote, quoted or indirectly quoted someone who said : >>That's really got nothing at all to do with what he's asking as far as I >>understood. > It is not what he asked for, but I think it is what he needs. How could setting the default output of a Java process possibly help redirecting the output of a non Java program that is not started by Java ? Liebe Gruesse, Joerg -- Ich lese meine Emails nicht, replies to Email bleiben also leider ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> |
|---|---|
| Date | 2014-03-22 11:24 +0000 |
| Message-ID | <slrnliqso3.rhr.avl@login.logic.tuwien.ac.at> |
| In reply to | #27811 |
Joerg Meier <joergmmeier@arcor.de> wrote: > On Sat, 22 Mar 2014 02:32:03 -0700, Roedy Green wrote: >> On Fri, 21 Mar 2014 23:59:57 +0100, Joerg Meier <joergmmeier@arcor.de> >> wrote, quoted or indirectly quoted someone who said : >>>That's really got nothing at all to do with what he's asking as far as I >>>understood. >> It is not what he asked for, but I think it is what he needs. > How could setting the default output of a Java process possibly help > redirecting the output of a non Java program that is not started by Java ? We don't know anything about the process whose output is to be discarded. We only know from the OP, that the process's parent is not a Java process. The subject itself can be interpreted such, that there may even be various processes writing to the monitor, and not just a specific one. PS: it might enable further help, if the OP clarified what exactly they even meant by "monitor", because we all seem to think of some terminal, but then again it might as well be some monitoring application watching other Java- processes' log4j traces... and drowning in currently irrelevant processes' outputs...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web