#creating a command

4 messages · Page 1 of 1 (latest)

shell steppe
#

Im trying to create a command "background" that runs a program in the background, and redirects standard in, out, and error. (this command should take at least four arguments)

void background(char *file){
        int filename = open(file, O_CREAT | O_TRUNC | O_WRONLY); //with O_CREAT -> no effect if file already exists
        //O_TRUNC -> reset its content if it does exist
        dup2(filename, STDOUT_FILENO);
        close(filename);

}
the command should ignore any > or & characters included

i get the error: "error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
50 | __open_missing_mode ()"

blissful fableBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

sinful agate
blissful fableBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.