fork and exec in bash

前端 未结 2 705
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条回答
  • 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 ...
    
    0 讨论(0)
  • 2021-01-30 20:13

    How about:

    (sleep 5; echo "Hello World") &
    
    0 讨论(0)
提交回复
热议问题