#FEEDBACK

17 messages · Page 1 of 1 (latest)

unique olive
#

Hi everyone, i have just coded a shell with the following goal:

In Unix-like system shells, you can hang the & character at the end of a command line to indicate that the command should be run in the background: i.e., the shell should not crash pending the termination of the command, but must continue parallel to the command and display the next prompt immediately. Implemented in dsh the execution of a command in the background through the character &.

I would love to receive feedbacks from you guys. I have no experience on this kind of things so if my program has any type of error or bug, please lemme know it.
Thank you guys!

green terraceBOT
#

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 tips on how to ask a good question use !howto ask.

dense mango
#

couple minor things (in order of appearance):

char _path[...] = ...;```
is global which is frowned upon since it has no reason of being such (it starting with an underscore might be UB as well. can quite remember)

```c
    do{
        cur++;
        if(buf[cur] == '\n'){
            buf[cur] = '\0';
            break;
        }
    }while(buf[cur] != '\0');```
although fine can be either replaced with `strchr` or just `buf[strcspn(buf, "\n")] = 0;`

and last - your `do_exec` has the potential of creating zombies processes (i.e. the `exec` process finished but its entry is still occupied). it might be better here to store all `pid`s within a vector like structure and `wait` on them at some point (either before your shell terminates or some other time)
pliant onyx
#

to avoid the zombie process issue, its best to set a handler for SIGCHLD

#

that triggers when a child exits

#

also, it would be best to use $PATH instead of hardcoding it

dense mango
#

that would be a better approach, though one need to call sigaction with SA_NOCLDSTOP

unique olive
#

Thank u guys!
Later i am gonna fix these things

green terraceBOT
#

@unique olive Has your question been resolved? If so, type !solved :)

plain wasp
#

There's also at least one potential uninitialized read

unique olive
plain wasp
green terraceBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
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.

unique olive
plain wasp
unique olive
#

Yeah

#

Obv, this is my first shell, i am learning about it