git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] help.c: wrap wait-only poll() invocation in sleep_millisec()

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 5, 2015, 19:45 UTC
Message-ID
<1bf3ed414ca35f378ac4934dee49a6fa595966ed.1433532968.git.j6t@kdbg.org>
In-Reply-To
<55700F10.8030806@kdbg.org>
We want to use the new function elsewhere in a moment.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 cache.h   | 1 +
 help.c    | 2 +-
 wrapper.c | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/cache.h b/cache.h
index 54f108a..328cdb7 100644
--- a/cache.h
+++ b/cache.h
@@ -1680,5 +1680,6 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
 void stat_validity_update(struct stat_validity *sv, int fd);
 
 int versioncmp(const char *s1, const char *s2);
+void sleep_millisec(int millisec);
 
 #endif /* CACHE_H */
diff --git a/help.c b/help.c
index 2072a87..de1279b 100644
--- a/help.c
+++ b/help.c
@@ -372,7 +372,7 @@ const char *help_unknown_cmd(const char *cmd)
 		if (autocorrect > 0) {
 			fprintf_ln(stderr, _("in %0.1f seconds automatically..."),
 				(float)autocorrect/10.0);
-			poll(NULL, 0, autocorrect * 100);
+			sleep_millisec(autocorrect * 100);
 		}
 		return assumed;
 	}
diff --git a/wrapper.c b/wrapper.c
index c1a663f..ff49807 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -595,3 +595,8 @@ int write_file(const char *path, int fatal, const char *fmt, ...)
 	}
 	return 0;
 }
+
+void sleep_millisec(int millisec)
+{
+	poll(NULL, 0, millisec);
+}
-- 
2.3.2.245.gb5bf9d3
Previous: Johannes SixtNext: Johannes Sixt
Message 10 of 12 in “lockfile: replace random() by rand()”
  1. lockfile: replace random() by rand()Johannes Sixt, May 30, 2015
  2. Junio C HamanoMay 30, 2015
  3. Johannes SixtJun 4, 2015
  4. Michael HaggertyJun 4, 2015
  5. Junio C HamanoJun 4, 2015
  6. 0/4 Fix file locking with retry and timeout on WindowsJohannes Sixt, Jun 5, 2015
  7. Junio C HamanoJun 5, 2015
  8. Michael HaggertyJun 5, 2015
  9. 1/4 lockfile: replace random() by rand()Johannes Sixt, Jun 5, 2015
  10. 2/4 help.c: wrap wait-only poll() invocation in sleep_millisec()Johannes Sixt, Jun 5, 2015
  11. 3/4 lockfile: convert retry timeout computations to millisecondJohannes Sixt, Jun 5, 2015
  12. 4/4 lockfile: wait using sleep_millisec() instead of select()Johannes Sixt, Jun 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.