-1

I just tried compiling code that I wrote a while ago using Gnu g++ in C++11 mode, to see if the code will need reworking anytime soon (I also plan to test it in C++17 mode for the same reason).

I found that the kill() function caused a compiler error and it seems that the kill function no longer exists in the signal.h header.

I just looked at http://www.cplusplus.com/reference/csignal/ as a reference which seems to confirm this is not just a Gnu-specific omission, but seems to be in the standard.

I can't find a rationale for this omission anywhere, nor can I find any proposal for how I should manage processes without it. Can anyone point me in the right direction?

Andy Rushton
  • 87
  • 1
  • 2

2 Answers2

3

C++ standard function is raise.

kill is a function required by POSIX standard.

C++ standard doesn't require this function, which means it is outside the scope of C++ standard.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
-1

OK, I was too quick to post that question, of course fork/kill etc are not part of the C++ standard in the first place but are common additions on unix-like platforms.

My real problem was that I used the wrong compiler switch. For anyone else hitting this problem, to get strict C++11 standard, use:

g++ -std=c++11

But to get the C++11 standard plus non-standard extensions use:

g++ -std=gnu++11

Using the latter, I can build and call fork/kill no problem.

Andy Rushton
  • 87
  • 1
  • 2
  • `kill` function is not a part of C or C++ standards, regardless of the compiler switch. It just so happens that in C++11 mode your compiler ends up including an extra system header declaring `kill` function. – Maxim Egorushkin Feb 25 '23 at 02:07