#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char const *argv[])
{
int fd[2], fork_status1, fork_status2;
char buff[20], str_[32];
if(pipe(fd) == -1) {
fprintf(stderr, "pipe - error!\n");
exit(-1);
} else {
fork_status1 = fork();
if(fork_status1 == -1) {
fprintf(stderr, "fork1 - error!\n");
exit(-2);
} else if(fork_status1 == 0) {
fork_status2 = fork();
if(fork_status2 == -1) {
fprintf(stderr, "fork2 - error!\n");
exit(-2);
} else if(fork_status2 == 0) { // Child process(2)
printf("Write smth(2)...\n");
while(strcmp(str_, "exit")) {
fgets(str_, 30, stdin);
write(fd[1], str_, strlen(str_));
}
exit(0);
} else { // Child process(1)
printf("Write smth(1)...\n");
while(strcmp(str_, "exit")) {
fgets(str_, 30, stdin);
printf("%s", str_); //<-----------------------------------
write(fd[1], str_, strlen(str_));
}
exit(0);
}
} else { // Parent process
while(strcmp(buff, "exit")) {
read(fd[0], buff, strlen(str_));
if(strcmp(buff, "exit")) {
//printf("%s\n", buff);
}
}
close(fd[0]);
close(fd[1]);
exit(0);
}
}
return 0;
}
<code><html>
<?php
if (!mysql_connect("localhost", "root", "")) // Ошибка исправляется доб. в php.ini "error_reporting = E_ALL & ~E_DEPRECATED"
echo "ERROR! ".mysql_errno()." ".mysql_error()."\n";
mysql_select_db("students");
mysql_set_charset("utf8");
$q = mysql_query ("SELECT * FROM `students` ORDER BY `students`.`id`")
or die("Invalid query: ".mysql_errno()." ".mysql_error()."\n");
$num_rows = mysql_num_rows($q); // кол-во строк
$num_fields = mysql_num_fields($q); // кол-во столбцов
$a=mysql_result($q, $_GET['id'], 0);
if (!isset($_GET['id']) || !isset($a))
die('User not find!');
?>
<head>
<title>
<?=
mysql_result($q, $_GET['id'], 1);
?>
</title>
<meta charset="utf-8" />
<meta name="description" content="... , <?=
mysql_result($q, $_GET['id'], 1);
?>" />
</head>
<body>
<h1>
...
</h1>
<h2>
Студент:
<?=
mysql_result($q, $_GET['id'], 1);
?>
</h2>
<h3>Возраст:</h3>
<p>
<?= mysql_result($q, $_GET['id'], 2); ?>
</p>
<h3>
Описание:
</h3>
<p>
<?= mysql_result($q, $_GET['id'], 3); ?>
</p>
<p><a href="students.php">Вернуться назад к Списку ...</a></p>
</body>
</html></code>