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 7098011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:00:15+00:00 2026-05-28T11:00:15+00:00

How can I detect system type / operating system in OCaml ? My current

  • 0

How can I detect system type / operating system in OCaml ?

My current idea is really weird. Running system call : "uname -a" with

let syscall ?(env=[| |]) cmd =
    let ic, oc, ec = Unix.open_process_full cmd env in
    let buf1 = Buffer.create 96
    and buf2 = Buffer.create 48 in
    (try
     while true do Buffer.add_channel buf1 ic 1 done
    with End_of_file -> ());
    (try
     while true do Buffer.add_channel buf2 ec 1 done
    with End_of_file -> ());
    let exit_status = Unix.close_process_full (ic, oc, ec) in
    check_exit_status exit_status;
    (Buffer.contents buf1,
    Buffer.contents buf2)

even on cygwin …

But I guess there must be some native for ocaml way to check system type.

  • 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-28T11:00:16+00:00Added an answer on May 28, 2026 at 11:00 am

    The standard OCaml library has a string named Sys.os_type, but it doesn’t contain as much information as uname -a. It is either "Unix", "Win32", or "Cygwin". It’s described in the manual entry for the Sys module.

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

Sidebar

Related Questions

I want to know how can we detect that operating system has killed my
Is there anyway that we can detect when the system/screen gets locked and notify
How can I detect if a system supports hardware virtualization via code? (Preferably in
I need to know how I can detect the current application pool I am
How can I detect when a System.Windows.Forms.WebBrowser control has completed loading? I tried to
Today I have seen this weird magic NTFS system supports: each file can have
Microsoft DxDiag can detect whether a system has Direct3D Acceleration. If the system has
Is there a machine learning concept (algorithm or multi-classifier system) that can detect the
I was wondering if there is a way I can detect the exact Operating
As Scott Myers wrote, you can take advantage of a relaxation in C++'s type-system

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.