Re: SYSTEM(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 10/11/2018 06:17, Michael Kerrisk (man-pages) wrote:
Hello Johnny,

On 11/9/18 12:50 PM, Jonny Grant wrote:
Hello Michael

I'm proposing a change below to two man pages.

execl(3) has NULL listed in that SYNOPSIS, so it would be consistent as
if system(3) was also NULL in this example below.


DESCRIPTION
The  system()  library  function uses fork(2) to create a child process
that executes the shell command specified in command using execl(3)  as
         follows:

             execl("/bin/sh", "sh", "-c", command, (char *) 0);
^ This should be NULL in example as per EXEC(3)?

Yes, I agree it would be more consistent. I made that change.

Thanks,

Michael

Hi Michael

Sounds good

BTW, I wonder if there are any others.

1) eg open.2 has an execl example with the same (char *) cast.
execl(buf, "some_prog", (char *) NULL);

EXEC(3) itself doesn't have an example, perhaps one could be added for each function?


http://man7.org/linux/man-pages/man2/open.2.html

BTW, C Spec says NULL is a pointer that doesn't have a type, there is no need to cast it to (char *) -- should that be taken out?

http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf


6.3.2.3 Pointers

3 An integer constant expression with the value 0, or such an expression cast to type
void *, is called a null pointer constant.
55) If a null pointer constant is converted to a
pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal
to a pointer to any object or function.
4 Conversion of a null pointer to another pointer type yields a null pointer of that type.
Any two null pointers shall compare equal.


2)
http://man7.org/linux/man-pages/man3/fmtmsg.3.html
Dummy arguments

has ((char *) 0)



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux