Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: implement wrapper for posix.fork()+posix.exec() #389

Closed
ignatenkobrain opened this issue Feb 6, 2018 · 4 comments
Closed

RFE: implement wrapper for posix.fork()+posix.exec() #389

ignatenkobrain opened this issue Feb 6, 2018 · 4 comments

Comments

@ignatenkobrain
Copy link
Contributor

Many of packages which use filetriggers (e.g glibc and systemd) use following construction:

pid = posix.fork()
if pid == 0 then
  assert(posix.exec("/foo/bar"))
elseif pid > 0 then
  posix.wait(pid)
end

this is just not user friendly and we could implement something like rpm.execute([args]) which would do all this boring things. Another option is definitely to create macro for this (like %rpm_lua_execute), but it's probably not user-friendly.

@fweimer
Copy link
Contributor

fweimer commented Feb 6, 2018

It might also be nice to use posix_spawn, which can be implemented more efficiently that the usual fork/execve sequence.

ignatenkobrain added a commit to ignatenkobrain/rpm that referenced this issue Feb 6, 2018
As Florian Weimer says, posix_spawn() can be implemented more
efficiently than usual fork() / execve() sequence.

Fixes: rpm-software-management#389
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
@ignatenkobrain
Copy link
Contributor Author

@n3npq except that RPM doesn't use lua posix module... It implements its own.

ignatenkobrain added a commit to ignatenkobrain/rpm that referenced this issue Feb 6, 2018
At this point, if you want to avoid using shell you have only option
which is to use posix.fork() and posix.exec() which is too verbose and
not optional (as Florian Weimer says, posix_spawn() can be implemented
more efficiently than usual fork() / execve() sequence).

Typical use-case is shown below.

-- Before
pid = posix.fork()
if pid == 0 then
  assert(posix.exec("/foo/bar"))
elseif pid > 0 then
  posix.wait(pid)
end
-- After
assert(posix.spawn("/foo/bar"))

Fixes: rpm-software-management#389
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
@ignatenkobrain
Copy link
Contributor Author

Submitted #390 for this.

ignatenkobrain added a commit to ignatenkobrain/rpm that referenced this issue Feb 6, 2018
At this point, if you want to avoid using shell you have only option
which is to use posix.fork() and posix.exec() which is too verbose and
not optimal (as Florian Weimer says, posix_spawn() can be implemented
more efficiently than usual fork() / execve() sequence).

Typical use-case is shown below.

-- Before
pid = posix.fork()
if pid == 0 then
  assert(posix.exec("/foo/bar"))
elseif pid > 0 then
  posix.wait(pid)
end
-- After
assert(posix.spawn("/foo/bar"))

Fixes: rpm-software-management#389
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
@pmatilai
Copy link
Member

pmatilai commented Jun 5, 2018

rpm.execute() added in commit 18e7923

@pmatilai pmatilai closed this as completed Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants