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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:04:27+00:00 2026-06-14T03:04:27+00:00

I want to execute background processes concurrently from a lua script like : a

  • 0

I want to execute background processes concurrently from a lua script

like :

a = io.popen("deploy.exp" .. ip1):read("*a")
b = io.popen("deploy.exp" .. ip2):read("*a")

where a,b are continually running processes. When i do this as above, b will only run when a is finished. And the deploy.exp script is an expect script which used to ssh few servers, and execute some commands. Then I need to fetch some text from a and b. Any idea on this? I tryed with the ExtensionProposal API. When I tried that I get one error messages that say: “* glibc detected free(): invalid next size (fast): 0x08aa2300 ** abort”.

The part code is

for k,v in pairs(single) do
command =  k .. " 1 " ..  table.concat(v, " ")
local out = io.pipe()
local pro = assert(os.spawn("./spaw.exp " .. command,{
      stdout = out,  
}))
if not proc then error("Failed to aprogrinate! "..tostring(err)) end
print(string.rep("#", 50))
local exitcode = proc:wait()
end

Has anybody any experience (or advice / where we should look) with this? or give me a sample? Thanks

BTW: I tried the luaposix, but I can’t find any sample by posix.fork(). Does anyone could share one? TKS

  • 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-06-14T03:04:28+00:00Added an answer on June 14, 2026 at 3:04 am

    posix.fork() is part of the luaposix library, which can be installed via luarocks. It works in much the same way as fork(3); it creates an copy of the parent process, and both of them will execute everything after the call to fork(). The return value of fork() is 0 in the child process, otherwise it’s the PID of the child that was just spawned. Here’s a contrived example:

    local posix = require "posix"
    local pid = posix.fork()
    
    if pid == 0 then 
      -- this is the child process
      print(posix.getpid('pid') .. ": child process")
    
    else 
      -- this is the parent process
      print(posix.getpid('pid') .. ": parent process")
    
      -- wait for the child process to finish
      posix.wait(pid) 
    
    end
    
    -- both processes get here
    print(posix.getpid('pid') .. ": quitting")
    

    This should output something like the following:

    $ lua fork.lua 
    27219: parent process
    27220: child process
    27220: quitting
    27219: quitting
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to run processes from rails script/console in the background? I
I'm having a strange issue when using subprocess.Popen.communicate(). For background, I want to execute
I have a script which allows to execute Bash processes in the background, i
I am relatively new to multi-threading and want to execute a background task using
I'm trying using pipes with boost libraries, I just want to execute a background
I want to execute a program which takes in 1 text file(say like Text.exe),
I want to execute a code helloword.cpp which takes in some argument from console
I want to execute a database query in a background thread. The OmniThread library
I need to execute a shell script. The catch is I want to do
I want to execute a Python script on several (15+) remote machine using SSH.

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.