On 7/17/08 9:31 AM, Mark Rivers wrote:
> I’ve done some more investigation of this. It appears that stdout is
> being closed and re-opened when the vxWorks startup script completes.
> Does anyone know if this is true? If so, I don’t understand why. I
> can understand why stdin may be reopened, changing from the startup
> script to the console. But why stdout? Is there a way to open a file
> descriptor to the console that will not be closed and re-opened when the
> startup script completes?
Hi, Mark.
I looked at src/iocsh/iocsh.cpp in EPICS base 3.14.9 and it seems to be
doing some special things with (FILE *) references to support
redirection. Maybe this is causing the problem? The comment in the
file indicates the original author was Marty Kraimer and that it was
modified by Eric Norum a little later.
There are about four places in the file where fclose() is called on a
(FILE *) reference. You could add a print statement before these to see
if this is indeed where stdout is getting closed.
But I bet Marty or Eric know better.
Lewis
> ------------------------------------------------------------------------
>
> *From:* Mark Rivers
> *Sent:* Wednesday, July 16, 2008 7:07 PM
> *To:* EPICS tech-talk
> *Subject:* stdout being changed in EPICS
>
>
>
> Folks,
>
>
>
> I have run into a problem with the value of stdout being changed some
> time after iocInit is called. This is happening at least on vxWorks, I
> have not checked other platforms.
>
>
>
> This is a real problem, because I have a vendor library that assigns a
> file descriptor to the value of stdout before iocInit is run, and then
> does fprintf() to that file descriptor for logging purposes. This works
> fine until just after iocInit is called, at which point that file
> descriptor is invalid (fprintf returns an error), and the value of
> stdout has changed to a new value.
>
>
>
> One can easily reproduce this problem with the example application that
> EPICS base generates. I just added this small global function
> show_stdout() to the end of devXxxSoft.c
>
>
>
> corvette> tail devXxxSoft.c
>
> /*If return was succesful then set undefined false*/
>
> if(!status) pxxx->udf = FALSE;
>
> return(0);
>
> }
>
>
>
> int show_stdout()
>
> {
>
> printf("stdout=%p\n", stdout);
>
> return(0);
>
> }
>
>
>
> Here is what I see at the end of the st.cmd file, to which I added calls
> to show_stdout just before and after iocInit:
>
>
>
> ****************************************************************************************************
>
> show_stdout
>
> stdout=0x1d0e290
>
> value = 0 = 0x0
>
> iocInit()
>
> Starting iocInit
>
> ############################################################################
>
> ### EPICS IOC CORE built on Jun 9 2008
>
> ### EPICS R3.14.8.2 $R3-14-8-2$ $2006/01/06 15:55:13$
>
> ############################################################################
>
> iocInit: All initialization complete
>
> value = 0 = 0x0
>
> show_stdout
>
> stdout=0x1d0e290
>
> value = 0 = 0x0
>
>
>
> ## Start any sequence programs
>
> seq &sncExample,"user=epics"
>
> SEQ Version 2.0.11: Mon Jun 9 16:03:45 2008
>
> Spawning state program "sncExample", thread 0x1c2e7c0: "sncExample"
>
> value = 29550528 = 0x1c2e7c0
>
>
>
> Done executing startup script
> /home/epics/devel/example/iocBoot/iocexample/st.cmd
>
> iocexample> show_stdout
>
> stdout=0x1ffe738
>
> value = 0 = 0x0
>
>
>
> ******************************************************************************************
>
>
>
> Note that the value of stdout is 0x1d0e290 before the call to iocInit,
> and just after iocInit returns. However, the value has changed to
> 0x1ffe738 when I type the show_stdout command manually a few seconds
> after I get the vxWorks prompt. This happens whether or not the SNL
> program is run (comment out the seq call).
>
>
>
> Does anyone know why the value of stdout is changing? It is a real
> problem for software that uses the value of stdout through a call to
> iocInit.
>
>
>
> Thanks,
>
> Mark
>
>
>
>
>
- Replies:
- Re: stdout being changed in EPICS Eric Norum
- References:
- RE: stdout being changed in EPICS Mark Rivers
- Navigate by Date:
- Prev:
RE: Building 32-bit EPICS binaries on 64-bit Linux systems Allison, Stephanie
- Next:
Re: stdout being changed in EPICS Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: stdout being changed in EPICS Mark Rivers
- Next:
Re: stdout being changed in EPICS Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|