I am making windows application which purpouse is to inform me on my connection downtimes and log them for later use/reporting. For now i use batch script to achieve the same goal and thought about incorporating it into the project but as i was investigating the subject i came across multiple advices that i should not ever use system
within any of my C++ programs. Most of the time the reason is that 'it is os specific' and 'resource demanding' i got the idea, but i am wondering: why is it bad that i use system
if my intent is to make app solely for Windows OS, especially if it will be lightweight program that will work in the background?
EDIT: I guess it needs clarification, so more sources:
-
- It’s a very expensive and resource heavy function call
- It’s not portable: Using system() makes the program very non-portable i.e. this works only on systems that have the pause command at the system level, like DOS or Windows. But not Linux, MAC OSX and most others.
I strongly disagree with using the system function (too long to quote here)
-
- system() is less flexible. (Fine with me)
- It offers no control of the command being executed. (Fine with me, I just need a return value from the script)
- It is not quite platform independent. (Now, this would be a concern. I would really love to see an example where it behaves differently on different platforms)
- It is a security concern. (Again, this would be an issue. Can someone provide an example of a potential security problem with system()? )
- system() is less flexible. (Fine with me)
Some of those arguments are irrelevant for my project for now so i do not mind them in this particular case, but combining all of those concerns i've read seem to indicate that one should avoid using system()
calls at all costs. So i figured out i should use another method (which i found a bunch of) but all of them seem a bit too complicated for me for now at least (i.e.: this instead of just attaching my already funcioning whole script which is about half of that length(25 lines))