fork and exec in bash

前端 未结 2 706
Happy的楠姐
Happy的楠姐 2021-01-30 20:04

How do I implement fork and exec in bash?

Let us suppose script as

echo \"Script starts\"

function_to_fork(){
sleep 5
echo \"Hello\"
}

echo \"Script en         


        
2条回答
  •  旧时难觅i
    2021-01-30 20:10

    Use the ampersand just like you would from the shell.

    #!/usr/bin/bash
    function_to_fork() {
       ...
    }
    
    function_to_fork &
    # ... execution continues in parent process ...
    

提交回复
热议问题