Skip to content

Instantly share code, notes, and snippets.

View dulimarta's full-sized avatar

Hans Dulimarta dulimarta

  • School of Computing and Information Systems, Grand Valley State University
  • Grand Rapids, Michigan
View GitHub Profile
@dulimarta
dulimarta / lab10_a.c
Last active April 4, 2024 13:57
CS452 Lab10 - Sample 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define KILO_BYTE 1024
#define AMOUNT 2
#define LOOP 200
int main()
{
@dulimarta
dulimarta / lab04_pipe_nodup.c
Last active February 9, 2024 01:52
CS452 Lab04 - Pipes - Sample 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <error.h>
#define READ 0
#define WRITE 1
#define MAX 1024
@dulimarta
dulimarta / lab02_c.rs
Created January 25, 2024 02:00
CS452 Lab02 - Sample 3 (Rust)
use nix::unistd::{fork, ForkResult};
// use nix::sys::wait::wait;
// use nix::sys::wait::WaitStatus;
use std::process;
fn main() {
let pid = fork();
match pid {
Ok(ForkResult::Child) => {
println!("I'm a child with PID {}", process::id());
@dulimarta
dulimarta / lab02_b.rs
Last active January 25, 2024 01:47
CS452 Lab02 - Sample 2 (Rust)
use std::env;
use nix::unistd::fork;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Not enough argument");
return;
}
@dulimarta
dulimarta / lab02_a.rs
Last active January 25, 2024 01:28
CS452 Lab02 - Sample 1 (Rust)
use nix::unistd::fork;
fn main() {
println!("Before fork()");
fork();
println!("After fork()");
}
@dulimarta
dulimarta / lab03_c.c
Last active February 13, 2023 02:09
CS452 Lab03 - fork() and signal()
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/wait.h>
bool running = true;
void sigHandler(int number) {
@dulimarta
dulimarta / lab04_dup.c
Last active February 2, 2023 03:48
CS452 Lab04 dup2()
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int main() {
char name[50];
int fd = open("myoutput.txt",
O_WRONLY | O_CREAT | O_EXCL,
@dulimarta
dulimarta / lab03_b.c
Created February 1, 2023 19:59
CS452 Lab04 - Pipes - Sample 2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define READ 0
#define WRITE 1
#define MAX 1024
int main () {
@dulimarta
dulimarta / lab01_b.c
Last active January 19, 2023 03:37
CS452 Lab01 - Sample 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 16
int main()
{
char *data1, *data2;
int k;
@dulimarta
dulimarta / eintr.c
Last active October 10, 2022 20:13
CS452 Lab3 - Interrupted Calls
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
int number = 0;
bool running = true;
void do_nothing(int s) {