Page MenuHomeFreeBSD

flua: lposix: add more useful functions for general purpose scripts
AcceptedPublic

Authored by kevans on Mar 15 2023, 5:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
May 21 2024, 12:48 AM
Unknown Object (File)
May 21 2024, 12:48 AM
Unknown Object (File)
May 21 2024, 12:48 AM
Unknown Object (File)
May 21 2024, 12:48 AM
Unknown Object (File)
May 16 2024, 4:41 PM
Unknown Object (File)
Apr 24 2024, 7:32 PM
Unknown Object (File)
Mar 28 2024, 1:00 AM
Unknown Object (File)
Mar 16 2024, 11:13 AM

Details

Reviewers
emaste
brooks
imp
Summary

unistd:

  • _exit
  • close
  • fork
  • getpid
  • pipe
  • read
  • write

libgen:

  • basename, dirname

stdlib:

  • realpath

These are sufficient for a number of real world scenarios. In our first
application of them, we use the libgen+stdlib additions to grab the
script dir based on argv[0]. The unistd assortment is then used to
outsource a bunch of work to forks and report back to the main process.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50981
Build 47872: arc lint + arc unit

Event Timeline

Use allocf, matches lua's internal naming

I don't understand why you need lposix_alloc and lposix_free at all vs direct call to free and malloc?

libexec/flua/modules/lposix.c
2–4

Why this extra line?

156

Why changing style?

libexec/flua/modules/lposix.c
5

care to add SPDX headers while here?

In D39083#898199, @bapt wrote:

I don't understand why you need lposix_alloc and lposix_free at all vs direct call to free and malloc?

Better form for a lua lib, though this one shouldn't see the light of day since it's a reimplementation of lposix so I could just simplify it.

overall looks good

libexec/flua/modules/lposix.c
107

is it ok to call this if inpath == NULL?

590

is it typical to use n for this? unless it's std lua convention maybe something more descriptive like narg?

kevans marked 5 inline comments as done.

Address comments; fix return consistency; a couple of missed return (3) and
one return (1) that should've been 3

libexec/flua/modules/lposix.c
107

D'oh, that should have had a return (3) otherwise the return value ends up being a bit nonsensical (and we leak two stack entries, iirc).

This revision is now accepted and ready to land.Sep 1 2023, 5:03 PM

So this looks generally good, modulo some error messages about having args having the function name and some not.

libexec/flua/modules/lposix.c
5

... and remove the boilerplate?

169

Close vs pclose in error message.

198

No name here? But close had one. Here and elsewhere

468

Why pclose?