e42.uk Circle Device

 

Quick Reference

Shell File Descriptor Handling

Imagine that you want to write some stuff to a file but you want to do it using a file descriptor.

exec 4<> $(mktemp)  # create a temporary file (read and write)
exec 4>&-           # close the file

C programme to use the open file descriptor:

int main(int argc, char *argv[]) {
    write(4, "Hello", 5);
}

References

Quick Links: Techie Stuff | General | Personal | Quick Reference