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

  • Home
  • SEARCH
  • 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 7682343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:32:47+00:00 2026-05-31T18:32:47+00:00

I found out the next issue in this simple code: let () = print_endline

  • 0

I found out the next issue in this simple code:

let () =
    print_endline "Hello";
    print_endline (Unix.getlogin ())

Running in the normal case, with ./a.out gives:

Hello
ricardo

But running like ./a.out </dev/null makes Unix.getlogin fail:

Hello
Fatal error: exception Unix.Unix_error(20, "getlogin", "")

Any idea why this happens?

  • 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-31T18:32:49+00:00Added an answer on May 31, 2026 at 6:32 pm

    Redirecting the input of a program overrides its controlling terminal. Without a controlling terminal, there is no login to be found:

    $ tty
    /dev/pts/2
    $ tty < /dev/null
    not a tty
    

    You can, however, still find a user’s name (perhaps) by getting the user’s id (getuid) and looking up his passwd entry (related docs) (getpwuid), then finding his username in it.

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

Sidebar

Related Questions

I found out how to generate an image in code-behind based on some input
Hoping someone out there might have had the same issue as this and have
Let me just first point out to any IE users right now (this is
I found out how to get the content of the NSPasteboard, and to copy
I found out that build time of C# solution with many projects gets much
I found out an application I wrote does not work properly under Windows Vista/7
I found out that I can use a different theme in an C# WPF
I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded
I found out that the FormWizard only __init__ 's once, when the url is
I found out recently that JList (finally!) was generified in JDK7. Why JTree and

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.