I'm relearning UNIX commands to use git on windows using MINGW32.
When I launch a program, for example "$ notepad hello.txt" I can't use the shell again until I close the notepad file or CTRL-C in the shell.
How do I essentially fork a new process so I can use both programs?
A new process can be created by the fork() system call. The new process consists of a copy of the address space of the original process. fork() creates new process from existing process. Existing process is called the parent process and the process is created newly is called child process.
In order to run a Bash script on your system, you have to use the “bash” command and specify the script name that you want to execute, with optional arguments. Alternatively, you can use “sh” if your distribution has the sh utility installed.
Add a &
to the end of the command:
notepad hello.txt &
Put an ampersand (&) at the end of the command line. That tells the shell to run the program in the background.
In UNIX, you can hit CTRL-z to suspend the currently running program (Instead of CTRL-c to kill it). Once it's suspended, you can use the 'bg' command to put it in the background. I don't think that will work on Windows, but you can try.
You can also create an alias in your .rc file so you don't have to add the ampersands each time.
I had some trouble doing this in bash on Cygwin though.
I ended up having to create a separate script file and add an alias to point to it.
Script file contents (filename is "dtextpad"):
#!/bin/bash.exe
C:/Program\ Files/TextPad\ 5/TextPad.exe $@ &
Alias in my .bashrc:
alias tp='~/include/bin/dtextpad'
Now if I want to open a file in textpad, I can type tp filename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With