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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:08:08+00:00 2026-05-22T03:08:08+00:00

I am writing a tool to log battery charge to a CSV file (I

  • 0

I am writing a tool to log battery charge to a CSV file (I know it’d be a bash one-liner but this is yet another Common Lisp learning exercise for me).

My plan is to slurp the entire battery state file into memory, as it’s guaranteed to be a tiny file. But file-length is consistently returning 0 for the file size, while working normally on other files:

* (defun stream-length (path)
    (with-open-file (stream path) 
            (file-length stream)))

STYLE-WARNING: redefining COMMON-LISP-USER::STREAM-LENGTH in DEFUN

STREAM-LENGTH
* (stream-length "/home/duncan/foo")

4
* (stream-length "/proc/acpi/battery/BAT0/state")

0

It turns out it’s not only SBCL; Perl behaves the same way:

$ perl -e 'print -s "/home/duncan/foo"; print "\n"'
4
$ perl -e 'print -s "/proc/acpi/battery/BAT0/state"; print "\n"'
0

But the file definitely contains something:

$ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mW
remaining capacity:      3945 mWh
present voltage:         10800 mV

So I’m presuming there’s something special about the state file. Could someone please enlighten me as to what it is?

  • 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-22T03:08:09+00:00Added an answer on May 22, 2026 at 3:08 am

    Most /proc files are special. Their contents don’t exist stored anywhere, but get produced on demand when a process opens and reads a given file. And the size of the contents may be different on every read. So, they generally don’t advertise any particular size.

    The correct approach is to simply open the file and read it until EOF.

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

Sidebar

Related Questions

I need a little guidance in writing a grammar to parse the log file
I'm writing a tool to gather customer configuration information. One of the questions I
I'm writing a logging tool which writes messages to a file, and I'm not
I am writing one tool and I need to gather some information about running
I'm writing a tool that requires data from a source. This source will be
I'm writing a tool in Perl that needs to scan for certain binary patterns
I'm writing a tool which will push changes to database after commit to svn.
I am writing a tool to scrape Javadoc from pre-existing Java source files and
I'm writing a tool which enables a user to interact with a bit of
I'm writing a GUI tool using PowerShell that is able to do most AD

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.