On Thursday 05 July 2012 08:27:51 Schooner did opine:

> Hi Gene
> 
> >>You did #include stdio.h I assume...
> 
> Yes and unistd.h etc, as I said it compiles fine in both and runs
> properly from the command line
> 
> >>I'm thinking that because of the type you used for 'fd', that it may
> >>well be volatile, and out of that functions 'scope' by the time you
> >>actually do the above write.
> 
> fd is a simple C int.

In the environment I was working in at that time, fd was actually an 
unsigned byte sized value because the system itself was comparatively 
small, on a pseudo 21 bit address that in my own system had been expended 
to 24 bits in order to address 2 megabytes of memory which was paged in and 
out of a 16 bit cpu's view.  Os9/Nitros9 on a Trash 80 Color Computer 3 
whose MC58B09EP cpu had been swapped out for the smarter Hitachi HD63C09EP.

That byte, IIRC was used as an offset into the opened device list that os9 
maintained.

> Rather than being a pointer, it is an index to a look-up table (the file
> descriptor table)

Much the same idea but a wider int as at least 32 bits of memory are 
available on modern machines.
 
> However you could be on to something, because stdin/stdout/stderr are
> predefined as 0,1 and 2 respectively so if the file descriptor is
> getting an erroneous value or losing the value it could still be
> pointing to a 'file', hence the print to screen
> 
> Yahoo, I have cracked it.
> 
> I was using the EXTRA_SETUP and EXTRA_CLEANUP macros to initiate serial
> connection and close and restore settings respectively. This was
> largely to keep the main section of code un-cluttered and easy to
> maintain.
> 
> Doing this necessitated a global fd accessed across several functions.
> 
> Changing the program flow, so that each function holds its own copy of
> fd, passed from the calling or called function, results in a perfectly
> executing component.
> 
> Thank you Gene, I just needed a kick in the right direction

It did seem to walk and quack like a 'scope' problem.  Glad I could help.
 
> regards

You're welcome.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux
over the wire". Film at 11.'
                -- Linus Torvalds

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to