Explorer les Livres électroniques
Catégories
Explorer les Livres audio
Catégories
Explorer les Magazines
Catégories
Explorer les Documents
Catégories
Exercice 2 (1 point). Donnez la/les commandes permettant d’envoyer les modifications sur le
fichier taratata vers le serveur.
Exercice 4 (4 points). Écrivez une fonction int affichecp(int infd, int outfd) qui reco-
pie le contenu du fichier infd à la fois dans outfd et sur la sortie standard.
A Prototypes de fonctions
void *alloca(size_t size);
int close(int fildes);
int closedir(DIR *dirp);
int chdir(const char *path);
int dirfd(DIR *dirp); /* donne un descripteur de fichier
correspondant a un repertoire */
int dup(int fildes);
int dup2(int fildes, int fildes2);
void exit(int status);
int execlp(const char *file, const char *arg0, ..., const char *argN, NULL);
int execvp(const char *file, char *const argv[]);
int fchdir(int fildes);
int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
pid_t fork(void);
int fstat(int fd, struct stat *buf);
int fstatat(int dirfd, const char *pathname, struct stat *buf,
int flags);
int ftruncate(int fildes, off_t length);
char *getenv(const char *name);
int getrlimit(int resource, struct rlimit *rlp);
pid_t getpid(void);
pid_t getppid(void);
int kill(pid_t pid, int sig);
off_t lseek(int fildes, off_t offset, int whence);
int lstat(const char *path, struct stat *buf);
int fstatat(int fd, const char *restrict path,
struct stat *restrict buf, int flag);
void *malloc(size_t size);
void *memcpy(void *s1, const void *s2, size_t n);
int mkdir(const char *path, mode_t mode);
int mkdirat(int dirfd, const char *pathname, mode_t mode);
void *mmap(void *addr, size_t len, int prot, int flags,
int fildes, off_t off);
int munmap(void *addr, size_t len);
int open(const char *path, int oflag, ...);
int openat(int dirfd, const char *pathname, int flags);
int openat(int dirfd, const char *pathname, int flags, mode_t mode);
DIR *opendir(const char *dirname);
int pause(void);
int pipe(int fildes[2]);
int poll(struct pollfd fds[], nfds_t nfds, int timeout);
ssize_t read(int fildes, void *buf, size_t nbyte);
struct dirent *readdir(DIR *dirp);
int rmdir(const char *path);
int setenv(const char *envname , const char *envval , int overwrite);
int sigemptyset(sigset_t *set);
int sigfillset(sigset_t *set);
struct dirent {
ino_t d_ino;
char d_name[];
char d_type; /* DT_DIR, DT_REG, DT_SOCK, DT_FIFO,
DT_BLK, DT_CHR, ou DT_LNK */
};
struct pollfd {
int fd;
short events;
short revents;
};
struct rlimit {
rlim_t rlim_cur; /* Soft limit */
rlim_t rlim_max; /* Hard limit (ceiling for rlim_cur) */
};
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* file type and mode */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for filesystem I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
};
/* st_mode can give the filetype with the following macros:
S_ISREG(m)
S_ISDIR(m)
S_ISCHR(m)
S_ISBLK(m)
S_ISFIFO(m)
S_ISLNK(m)
S_ISSOCK(m)
*/
struct sigaction {
void (*sa_handler)(int);
sigset_t sa_mask;
int sa_flags;
};
Drapeaux pour open : O_EXEC, O_RDONLY, O_RDWR, O_WRONLY, O_APPEND, O_CREAT, O_TRUNC.
Drapeaux pour lseek : SEEK_SET, SEEK_CUR, SEEK_END.
Drapeaux pour poll : POLLIN, POLLOUT, POLLHUP, POLLERR.
Drapeaux pour getrlimit/setrlimit : RLIMIT_AS (mémoire totale), RLIMIT_STACK (taille du
tas), RLIMIT_NOFILE (nombre de fichiers), RLIMIT_FSIZE (taille maximale d’un fichier créé),
RLIMIT_CPU (temps maximal CPU).
Drapeaux pour sigprogmask (how) : SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK
B Signaux POSIX
Liste de signaux : SIGHUP, SIGINT, SIGINT, SIGILL, SIGTRAP, SIGIOT, SIGBUS, SIGFPE, SIG-
KILL, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM, SIGSTKFLT, SIGCHLD, SIGCONT,
SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIG-
WINCH, SIGIO, SIGPWR.
SIGABRT A Process abort signal.
SIGALRM T Alarm clock.
SIGBUS A Access to an undefined portion of a memory object.
SIGCHLD I Child process terminated, stopped, or continued.
SIGCONT C Continue executing, if stopped.
SIGFPE A Erroneous arithmetic operation.
SIGHUP T Hangup.
SIGILL A Illegal instruction.
SIGINT T Terminal interrupt signal (CTRL+C).
SIGKILL T Kill (cannot be caught or ignored).
SIGPIPE T Write on a pipe with no one to read it.
SIGQUIT A Terminal quit signal (CTRL+\).
SIGSEGV A Invalid memory reference.
SIGSTOP S Stop executing (cannot be caught or ignored).
SIGTERM T Termination signal.
SIGTSTP S Terminal stop signal (CTRL+Z).
SIGTTIN S Background process attempting read.
SIGTTOU S Background process attempting write.
SIGUSR1 T User-defined signal 1.
SIGUSR2 T User-defined signal 2.
SIGPOLL T Pollable event.
SIGPROF T Profiling timer expired.
SIGSYS A Bad system call.
SIGTRAP A Trace/breakpoint trap.
SIGURG I High bandwidth data is available at a socket.
SIGVTALRM T Virtual timer expired.
SIGXCPU A CPU time limit exceeded.
SIGXFSZ A File size limit exceeded.