Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3603802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:55:03+00:00 2026-05-18T20:55:03+00:00

Is there any way to open a terminal device file in erlang ? I

  • 0

Is there any way to open a terminal device file in erlang ?

I am on Solaris and I am trying the following::

Erlang (BEAM) emulator version 5.6 [source] [64-bit] [async-threads:0] [kernel-poll:false]

/xlcabpuser1/xlc/abp/arunmu/Dolphin/ebin
Eshell V5.6  (abort with ^G)
1> file:open("/dev/pts/2",[write]).
{error,eisdir}
2> file:open("/dev/null",[write]).
{ok,}
3>

As can be seen above the erlang file driver has no problem in opening a null fle but does not open a terminal device file!!

Unable to come to a conclusion as the file driver is able to open a null file.

Is there any other way to open terminal device files ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:55:04+00:00Added an answer on May 18, 2026 at 8:55 pm

    Update: I was able to work around the limitation described below using a port. For example, here is a sample program that prints “hello world” to /dev/stdout:

    -module(test).
    -export([main/1]).
    
    main(X) ->
        P = open_port({spawn, "/bin/cat >/dev/stdout"}, [out]),
        P ! {self(), {command, "hello world"}}.
    

    This is a bit inconvenient because a port doesn’t act like a regular file, but at least it’s one way to get the job done.


    In efile_openfile() (in erts/emulator/drivers/unix/unix_efile.c) there is the following code:

        if (stat(name, &statbuf) >= 0 && !ISREG(statbuf)) {
    #if !defined(VXWORKS) && !defined(OSE)
            /*
             * For UNIX only, here is some ugly code to allow
             * /dev/null to be opened as a file.
             *
             * Assumption: The i-node number for /dev/null cannot be zero.
             */
            static ino_t dev_null_ino = 0;
    
            if (dev_null_ino == 0) {
                struct stat nullstatbuf;
    
                if (stat("/dev/null", &nullstatbuf) >= 0) {
                    dev_null_ino = nullstatbuf.st_ino;
                }
            }
            if (!(dev_null_ino && statbuf.st_ino == dev_null_ino)) {
    #endif
                errno = EISDIR;
                return check_error(-1, errInfo);
    #if !defined(VXWORKS) && !defined(OSE)
            }
    #endif
        }
    

    This code (confusingly) returns the EISDIR error if the file is not a regular file (which is the ISREG(statbuf) check), unless the file specifically is /dev/null. The file(3) documentation states:

         eisdir :
           The named file is not a regular file. It  may  be  a  directory,  a
           fifo, or a device.
    

    so it’s actually documented to do that. I’m not sure why that restriction exists, though—perhaps it’s got something to do with performance because device drivers might block for more time than an ordinary file generally will.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to copy all lines from open file to clipboard in
Is there any way in Spotlight to have a folder open in a Terminal
Is there any way to open an html file from within a zip file
Is there any way to open a broadcast bluetooth socket, take a listen and
Is there any way to programmatically tell android to open the keyboard when the
Is there any way to pop-up TIPS and pop-over any other windows open? I
Is there any way to know for events when move a window with window.open?.
Is there any way to open Internet Explorer process from C#, send html content
Is there any way to open a new activity as a popup window on
Is there any way to open a page in the browser by clicking the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.