[Chicken-users] about egg/pty
hi all by browsing the code of pty egg (http://wiki.call-cc.org/eggref/4/pty) in source code http://code.call-cc.org/svn/chicken-eggs/release/4/pty/trunk/pty.scm the procedure raw-open-pty uses a magic number 1024 , which used to pack master fd and slave fd into one integer to return. but why 1024 and what happens when the slave fd is greater than 1024? just curious. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] about egg/pty
hi all by browsing the code of pty egg (http://wiki.call-cc.org/eggref/4/pty) in source code http://code.call-cc.org/svn/chicken-eggs/release/4/pty/trunk/pty.scm the procedure raw-open-pty uses a magic number 1024 , which used to pack master fd and slave fd into one integer to return. but why 1024 and what happens when the slave fd is greater than 1024? just curious. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] about egg/pty
Hi! Chaos Eternal writes: > uses a magic number 1024 , which used to pack master fd and slave fd > into one integer to return. > > but why 1024 and what happens when the slave fd is greater than 1024? I am not the author but 1024 happens to be the default maximum number of open files for most systems(tm). And yes if that assumption is wrong it will break and do strange things. As I see it it's just a quick hack to get both values out of C without further FFI tricks. Maybe I am wrong and Alex can explain the rationale behind it, if there is any. Kind regards, Christian -- May you be peaceful, may you live in safety, may you be free from suffering, and may you live with ease. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] about egg/pty
1024 is the default value of FD_SETSIZE i.e. the largest fd one can use with select(), so I think you have the right idea. Use of a magic constant might be reconsidered though. Could also convert the code to use poll() like Chicken core was some time ago. Jim > On Feb 20, 2015, at 02:27, Christian Kellermann wrote: > > Hi! > > Chaos Eternal writes: > >> uses a magic number 1024 , which used to pack master fd and slave fd >> into one integer to return. >> >> but why 1024 and what happens when the slave fd is greater than 1024? > > I am not the author but 1024 happens to be the default maximum number of > open files for most systems(tm). > > And yes if that assumption is wrong it will break and do strange things. > > As I see it it's just a quick hack to get both values out of C without > further FFI tricks. Maybe I am wrong and Alex can explain the rationale > behind it, if there is any. > > Kind regards, > > Christian > > -- > May you be peaceful, may you live in safety, may you be free from > suffering, and may you live with ease. > > > ___ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] about egg/pty
Yes, it was a quick hack, and if I recall inspired by another egg which did something similar (maybe ssl?). Patches for large fileno support are welcome. As Jim says, you'd also need to switch the select(2) handling to use poll(2), although it's probably better to remove the manual non-blocking support and just use open-input/output-file* from the posix library. -- Alex On Sat, Feb 21, 2015 at 12:24 PM, Jim Ursetto wrote: > 1024 is the default value of FD_SETSIZE i.e. the largest fd one can use > with select(), so I think you have the right idea. Use of a magic constant > might be reconsidered though. Could also convert the code to use poll() > like Chicken core was some time ago. > Jim > > > > On Feb 20, 2015, at 02:27, Christian Kellermann > wrote: > > > > Hi! > > > > Chaos Eternal writes: > > > >> uses a magic number 1024 , which used to pack master fd and slave fd > >> into one integer to return. > >> > >> but why 1024 and what happens when the slave fd is greater than 1024? > > > > I am not the author but 1024 happens to be the default maximum number of > > open files for most systems(tm). > > > > And yes if that assumption is wrong it will break and do strange things. > > > > As I see it it's just a quick hack to get both values out of C without > > further FFI tricks. Maybe I am wrong and Alex can explain the rationale > > behind it, if there is any. > > > > Kind regards, > > > > Christian > > > > -- > > May you be peaceful, may you live in safety, may you be free from > > suffering, and may you live with ease. > > > > > > ___ > > Chicken-users mailing list > > Chicken-users@nongnu.org > > https://lists.nongnu.org/mailman/listinfo/chicken-users > > ___ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users > ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users