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
F82032528: D39083.diff
Wed, Apr 24, 7:32 PM
Unknown Object (File)
Thu, Mar 28, 1:00 AM
Unknown Object (File)
Mar 16 2024, 11:13 AM
Unknown Object (File)
Mar 16 2024, 11:13 AM
Unknown Object (File)
Mar 16 2024, 11:13 AM
Unknown Object (File)
Mar 16 2024, 11:13 AM
Unknown Object (File)
Mar 16 2024, 10:31 AM
Unknown Object (File)
Dec 25 2023, 1:34 PM

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?