Convert the char in command line argument into int type

 

Compiling a C Program on the Windows Command Line

1. Open a developer command prompt. In Windows 8, on the Start screen, open the Visual Studio Tools folder and then choose the Developer Command Prompt shortcut. In earlier versions, choose the Start button, expand All Programs, Microsoft Visual Studio, and Visual Studio Tools, and then choose Developer Command Prompt.

Depending on the version of Windows on the computer and the system security configuration, you might have to open the shortcut menu for Developer Command Prompt and then choose Run as Administrator to successfully build and run the application that you create by following these steps.

2. In Notepad, enter the following lines:

3. At the command prompt, specify the cl command together with the name of your source file—for example, cl eje.c—and press Enter to compile the program. The cl.exe compiler generates an .obj file that contains the compiled code, and then runs the linker to build an executable program that has the name of your source file, but has an .exe file name extension—for example, simple.exe.

4. To run your program, type its name without the file name extension—for example, eje—and press Enter.

holamundoC

Programación de procesos en Linux

Introducción a la gestión de procesos en Linux

Funciones para la gestión de procesos en Linux

getpid, getppid, getuid, geteuid, getgid and getegid (System Calls) (ejemplo)

 

getuid, geteuid, getgid and getegid (System Calls) (example)

 

shmctl (System Call)

NAME

shmctl – XSI shared memory control operations

SYNOPSIS

DESCRIPTION

The shmctl() function operates on XSI shared memory (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.340, Shared Memory Object). It is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in Realtime.

The shmctl() function provides a variety of shared memory control operations as specified by cmd. The following values for cmd are available:

IPC_STAT

Place the current value of each member of the shmid_ds data structure associated with shmid into the structure pointed to by buf. The contents of the structure are defined in <sys/shm.h>.

IPC_SET

Set the value of the following members of the shmid_ds data structure associated with shmid to the corresponding value found in the structure pointed to by buf:
shm_perm.uid
shm_perm.gid
shm_perm.mode Low-order nine bits.
IPC_SET can only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds data structure associated with shmid.

IPC_RMID

Remove the shared memory identifier specified by shmid from the system and destroy the shared memory segment and shmid_ds data structure associated with it. IPC_RMID can only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds data structure associated with shmid.

RETURN VALUE

Upon successful completion, shmctl() shall return 0; otherwise, it shall return -1 and set errno to indicate the error.

ERRORS

The shmctl() function shall fail if:

[EACCES]
The argument cmd is equal to IPC_STAT and the calling process does not have read permission; see XSI Interprocess Communication.
[EINVAL]
The value of shmid is not a valid shared memory identifier, or the value of cmd is not a valid command.
[EPERM]
The argument cmd is equal to IPC_RMID or IPC_SET and the effective user ID of the calling process is not equal to that of a process with appropriate privileges and it is not equal to the value of shm_perm.cuid or shm_perm.uid in the data structure associated with shmid.

The shmctl() function may fail if:

[EOVERFLOW]
The cmd argument is IPC_STAT and the gid or uid value is too large to be stored in the structure pointed to by the buf argument.

getegid (System Call)

NAME

getegid – get the effective group ID

SYNOPSIS

DESCRIPTION

The getegid() function shall return the effective group ID of the calling process.

RETURN VALUE

The getegid() function shall always be successful and no return value is reserved to indicate an error.

ERRORS

No errors are defined.

shmat (System Call)

NAME

shmat – XSI shared memory attach operation

SYNOPSIS

DESCRIPTION

The shmat() function operates on XSI shared memory (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.340, Shared Memory Object). It is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in Realtime.

The shmat() function attaches the shared memory segment associated with the shared memory identifier specified by shmid to the address space of the calling process. The segment is attached at the address specified by one of the following criteria:

If shmaddr is a null pointer, the segment is attached at the first available address as selected by the system.

If shmaddr is not a null pointer and (shmflg &SHM_RND) is non-zero, the segment is attached at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)). The character ‚%‘ is the C-language remainder operator.

If shmaddr is not a null pointer and (shmflg &SHM_RND) is 0, the segment is attached at the address given by shmaddr.

The segment is attached for reading if (shmflg &SHM_RDONLY) is non-zero and the calling process has read permission; otherwise, if it is 0 and the calling process has read and write permission, the segment is attached for reading and writing.

RETURN VALUE

Upon successful completion, shmat() shall increment the value of shm_nattch in the data structure associated with the shared memory ID of the attached shared memory segment and return the segment’s start address.

Otherwise, the shared memory segment shall not be attached, shmat() shall return -1, and errno shall be set to indicate the error.

ERRORS

The shmat() function shall fail if:

[EACCES]
Operation permission is denied to the calling process; see XSI Interprocess Communication.

[EINVAL]
The value of shmid is not a valid shared memory identifier, the shmaddr is not a null pointer, and the value of (shmaddr -((uintptr_t)shmaddr %SHMLBA)) is an illegal address for attaching shared memory; or the shmaddr is not a null pointer, (shmflg &SHM_RND) is 0, and the value of shmaddr is an illegal address for attaching shared memory.

[EMFILE]
The number of shared memory segments attached to the calling process would exceed the system-imposed limit.

[ENOMEM]
The available data space is not large enough to accommodate the shared memory segment.