Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin/lab9 10 #714

Open
wants to merge 6 commits into
base: kutalev/accepted
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# some musom
core
core.*
.nfs*
.DS_Store
2 changes: 2 additions & 0 deletions 23213/a.chepenkov/lab20/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main: lab20.c
gcc lab20.c -Wall -Wextra -Werror -pedantic -std=c99 -o main
37 changes: 37 additions & 0 deletions 23213/a.chepenkov/lab20/lab20.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <string.h>
#include <glob.h>
#include <errno.h>

int errfunc(const char *epath, int eerrno) {
if (eerrno != ENOTDIR) {
fprintf(stderr, "%s: %s\n", epath, strerror(eerrno));
}
return 0;
}

int main() {
glob_t glob_struct;
int glob_res;
char** matched;
char pattern[BUFSIZ];
fgets(pattern, BUFSIZ, stdin);

if (pattern[strlen(pattern) - 1] == '\n') {
pattern[strlen(pattern) - 1] = '\0';
}

glob_res = glob(pattern, 0, &errfunc, &glob_struct);
if (glob_res == GLOB_NOMATCH) {
printf("No files found with pattern: %s\n", pattern);
return -1;
}

matched = glob_struct.gl_pathv;
while (*matched) {
printf("%s\n", *matched);
matched++;
}
globfree(&glob_struct);
return 0;
}
43 changes: 43 additions & 0 deletions 23217/m.baev/lab2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <sys/types.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
extern char *tzname[];

int main() {
time_t now;
struct tm *sp;

if(setenv("TZ", "America/Los_Angeles", 1) == -1) {

fprintf(stderr, "setenv error\n");
return 1;
}
//tzset();

now = time(NULL);
if (now == -1) {
fprintf(stderr, "Get time error\n");
return 1;
}

char *time_now = ctime(&now);
if (time_now == NULL) {
fprintf(stderr, "ctime error\n");
return 1;
}
printf("%s", time_now);

sp = localtime(&now);
if (sp == NULL) {

fprintf(stderr, "Get time error\n");
return 1;
}
printf("%d/%d/%02d %d:%02d %s\n",
sp->tm_mon + 1, sp->tm_mday,
sp->tm_year, sp->tm_hour,
sp->tm_min, tzname[sp->tm_isdst]);

return 0;
}
1 change: 1 addition & 0 deletions 23217/m.baev/lab9_10/long_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
Binary file added 23217/m.baev/lab9_10/main
Binary file not shown.
23 changes: 23 additions & 0 deletions 23217/m.baev/lab9_10/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int main() {
int status;
pid_t pid = fork();

if (pid < 0) {
perror("fork failed");
}

if (pid == 0) {
execlp("cat", "cat", "long_file.txt", NULL);
}

else {
printf("end subprocess pid %d with status %d\n", wait(&status), WEXITSTATUS(status));
printf("Hello world!\n");
}

return 1;
}