Subversion Repositories Okuu

Rev

Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13 Rev 14
Line 1... Line 1...
1
/* $Id: bot.c 13 2024-09-12 15:29:22Z nishi $ */
1
/* $Id: bot.c 14 2024-09-12 22:19:34Z nishi $ */
2
 
2
 
3
#include "ok_bot.h"
3
#include "ok_bot.h"
4
 
4
 
5
#include "ok_util.h"
5
#include "ok_util.h"
6
#include "ok_news.h"
6
#include "ok_news.h"
Line 42... Line 42...
42
 
42
 
43
int ok_sock;
43
int ok_sock;
44
struct sockaddr_in ok_addr;
44
struct sockaddr_in ok_addr;
45
 
45
 
46
void ok_close(int sock) {
46
void ok_close(int sock) {
-
 
47
	char c;
47
	while(close(sock) == 0);
48
	while(close(sock) == 0);
-
 
49
	while(recv(sock, &c, 1, 0) > 0);
48
}
50
}
49
 
51
 
50
void ok_bot_kill(int sig) {
52
void ok_bot_kill(int sig) {
51
	fprintf(stderr, "Shutdown\n");
53
	fprintf(stderr, "Shutdown\n");
52
	ircfw_socket_send_cmd(ok_sock, NULL, "QUIT :Shutdown (Signal)");
54
	ircfw_socket_send_cmd(ok_sock, NULL, "QUIT :Shutdown (Signal)");
Line 245... Line 247...
245
					} else if(sentin[0] == '#') {
247
					} else if(sentin[0] == '#') {
246
						/* This was sent in channel */
248
						/* This was sent in channel */
247
						pid_t pid = fork();
249
						pid_t pid = fork();
248
						int code;
250
						int code;
249
						if(pid == 0){
251
						if(pid == 0){
-
 
252
							close(ok_sock);
250
							_exit(ok_news_write(nick, msg));
253
							_exit(ok_news_write(nick, msg));
251
						}else{
254
						}else{
252
							int status;
255
							int status;
253
							waitpid(pid, &status, 0);
256
							waitpid(pid, &status, 0);
254
							code = WEXITSTATUS(status);
257
							code = WEXITSTATUS(status);